views:

571

answers:

3

I am having a terrible time getting this to work, and the Apple Developer forum has been of no help.

I have an application that plays video and when the moviecontrols are displayed and the iPad is rotated, the status bar sticks to the orientation that the video was in before the orientation begins. Then there is a 20px gap at the top of the view while the statusbar in another orientation.

Has anyone seen this problem?

Any help would be greatly appreciated.

A: 

Yes, i'm seeing this problem too and trying to resolve it.

Did you figure it out?

bandejapaisa
+3  A: 

I had the same issue, plus my view was still screwed up after returning the movie player to windowed mode. I don't know how to fix this during fullscreen play, but at least after switching back to windowed you can fix up the status bar like this:

  • register an observer for MPMoviePlayerWillExitFullscreenNotification
  • in the notification callback function, launch an NSTimer to call another function a bit (like 0.1s) later
  • in the timer function do

    [[UIApplication sharedApplication] setStatusBarOrientation:[[UIDevice currentDevice] orientation] animated:NO];

imre
+1  A: 

I had the same problem:

  • start application in portrait (for instance)
  • launch video player (ours is shown using presentModalViewController).
  • rotate iPad
  • exit video by pressing 'Done'.

Bam! Our application's layout is broken (we do some custom layout for each orientation), and the status bar is at the wrong place, despite being at the correct place when in video.

I did two things to fix the two issues :

  • make sure our custom configuration, which is done in viewWillAppear, is done AFTER calling `[super viewWillAppear];.
  • implement observers for MPMoviePlayerDidExitFullscreenNotification and MPMoviePlayerPlaybackDidFinishNotification (the first one never got called when clicking 'Done' in my case).

The code for the observer's callback is looking like this:

[self performSelector: @selector(checkAndFixStatusBar)
           withObject: nil
           afterDelay: 0];

[[NSNotificationCenter defaultCenter] removeObserver: self];

And the final method, called after an intentional 0 delay:

- (void)checkAndFixStatusBar
{
    UIInterfaceOrientation intOrient = self.interfaceOrientation;
    UIInterfaceOrientation sbOrient = [[UIApplication sharedApplication] statusBarOrientation];

    if (intOrient != sbOrient)
    {
        [[UIApplication sharedApplication] setStatusBarOrientation: intOrient animated: NO];
        NSLog(@"Fixed status bar orientation"); 
    }
}

There is still a perceivable blinking of the status bar, but that's the best I came up with.

Hope this helps.

EDIT: I've removed the performSelector step, and directly called the status bar setup, in my case, it makes no noticeable difference (still blinking).

jv42