问题
I have an MPMoviePlayerViewController in my application and am using that to play videos in fullscreen.
This works fine on IOS 5 OS on iPad.
But on iOS 6 on iPad 3, after playing the video, the status bar disappears and is replaced by a white space.
Is it sloppy to use [[UIApplication sharedApplication]setStatusBarHidden:NO];
to restore the status bar everywhere I have a video?
As my app is very big, can anyone provide an alternate method?
回答1:
I added an observer to the MPMoviePlayerDidExitFullscreenNotification. In this observer, I create an NSTimer to fire two seconds later. Within the message that the NSTimer fires, I reset the status bar style as well as the status bar. The timer is required because I noticed that the status bar goes into an inconsistent state much after the animations for exiting out of full screen complete.
So in the ViewController which manages the MPMoviePlayer, I do the following:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidExitFullScreenCallback:) name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayerController];
Then within the notification selector:
- (void) moviePlayerDidExitFullScreenCallback:(NSNotification *)aNotification {
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(setStatusBarVisible:) userInfo:nil repeats:NO];
}
and within the setStatusBarVisible selector:
- (void) setStatusBarVisible: (NSTimer *)timer {
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
[[UIApplication sharedApplication] setStatusBarHidden:NO];
}
回答2:
I've encountered this same problem, it seems there is some issue with iOS 6 when using
MPMovieControlStyleEmbeded with FullScreen = YES
it may fail to play the video or calling the player twice, which creates some frame positioning issues.
I end up have to change the whole app to use presentMoviePlayerViewControllerAnimated from the view controller which seems to be a more proper way to play video in this new iOS 6
MPMoviePlayerController fullscreen mode issue
来源:https://stackoverflow.com/questions/12618981/ios-6-status-bar-not-showing-after-playing-video