Reputation: 46
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.
Upvotes: 3
Views: 1687
Reputation: 8593
I had the same problem:
presentModalViewController
).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 :
viewWillAppear
, is done AFTER calling [super viewWillAppear];
.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).
Upvotes: 2
Reputation: 1717
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:
in the timer function do
[[UIApplication sharedApplication] setStatusBarOrientation:[[UIDevice currentDevice] orientation] animated:NO];
Upvotes: 2