iOS 7 Status Bar Disappears After Playing a Video

为君一笑 提交于 2019-12-23 07:38:41

问题


I'm not the only one who's having this kind of issue. Here's another one, Status bar height changes after playing a Youtube video. But I can't still find a way to solve this. I'm not using MPMoviePlayerController. I think I just have to use these codes;

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:NO];

self.webView.frame = CGRectMake(0.0,
                                20.0,
                                self.webView.frame.size.width,
                                self.webView.frame.size.height);

But it's not so working.

Please see this images below..

At first this is what my "Home" looks like.

Status bar disappears while playing a video from Youtube/Vimeo (or whatever).

When I go back, see them bunched up.

Found out that FB figure out how to handle this. They had their status bar appears right there.

Any help???

Cheers in advance!


回答1:


I don't know if apply for your case, but in my case the status bar appears after I loaded a UIImagePickerController and change my default screen orientation.

I fix this situation add application.statusBarHidden = YES; inside appDelegate like this:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
// Detect if I need to hide the StatusBar (optional)
if (iNeedToHide == YES) {  
    application.statusBarHidden = YES;
}
return UIInterfaceOrientationMaskLandscape;

}

I hope this helps you.




回答2:


I had to disable the animation when dismissing the video player. Place a notification for video did finish event:

[[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:controller.moviePlayer];

Then, inside the method, dismiss the view controller without animation:

- (void)videoDidFinish:(NSNotification *)notification {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:controller.moviePlayer];
    [self dismissViewControllerAnimated:NO completion:nil];
}


来源:https://stackoverflow.com/questions/19291562/ios-7-status-bar-disappears-after-playing-a-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!