IOS 6 - 播放视频后不显示状态栏 [英] IOS 6 - Status Bar Not Showing after Playing video

查看:32
本文介绍了IOS 6 - 播放视频后不显示状态栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有一个 MPMoviePlayerViewController,我用它来全屏播放视频.

I have an MPMoviePlayerViewController in my application and am using that to play videos in fullscreen.

这适用于 iPad 上的 IOS 5 操作系统.

This works fine on IOS 5 OS on iPad.

但在 iPad 3 上的 iOS 6 上,播放视频后,状态栏消失并被空白替换.

But on iOS 6 on iPad 3, after playing the video, the status bar disappears and is replaced by a white space.

使用[[UIApplication sharedApplication]setStatusBarHidden:NO]是不是马虎了;在我有视频的任何地方恢复状态栏?

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?

推荐答案

我向 MPMoviePlayerDidExitFullscreenNotification 添加了一个观察者.在这个观察者中,我创建了一个 NSTimer 以在两秒后触发.在 NSTimer 触发的消息中,我重置了状态栏样式以及状态栏.计时器是必需的,因为我注意到状态栏在退出全屏的动画完成后很长时间进入不一致状态.

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.

因此在管理 MPMoviePlayer 的 ViewController 中,我执行以下操作:

So in the ViewController which manages the MPMoviePlayer, I do the following:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidExitFullScreenCallback:) name:MPMoviePlayerDidExitFullscreenNotification object:self.moviePlayerController];

然后在通知选择器中:

- (void) moviePlayerDidExitFullScreenCallback:(NSNotification *)aNotification {

    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(setStatusBarVisible:) userInfo:nil repeats:NO];

}

在 setStatusBarVisible 选择器中:

and within the setStatusBarVisible selector:

- (void) setStatusBarVisible: (NSTimer *)timer {
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
}

这篇关于IOS 6 - 播放视频后不显示状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆