MPMoviePlayerController可以全屏退出,但顶部栏消失了 [英] MPMoviePlayerController can exit fullscreen but topbar is gone
问题描述
我正在使用 MPMoviePlayerController
在iPad上播放电影.
I am streaming a movie on the iPad using MPMoviePlayerController
.
当用户将设备旋转到横向时,我将其设置为全屏.
When the user rotates the device to landscape, I animate it to fullscreen.
如果用户随后点击"退出全屏"或完成",则电影将动画返回其小帧(自然行为),但会-顶部栏(导航栏)不见了.另外,可见的视图也向上移动,在状态栏的后面和之外.
If the user then taps 'exit fullscreen' or 'done', the movie animates back to its small frame (native behavior), BUT-- the top bar (navigation bar) is gone. Also, the visible views have moved upwards, behind and beyond the status bar.
请注意,我没有触摸任何顶部栏.我还没有手动隐藏它.
Note that I haven't touched the top bar whatsoever. I have not manually hidden it.
我尝试通过将setNavigationBarHidden:animated
发送到当前ViewController的导航控制器以及TabbarController的NavigationController来重新获得导航栏.我将其作为对MPMoviePlayerDidExitFullscreenNotification
的响应(触发).没有效果.但是,如果我们旋转回纵向,它会立即返回.
I have tried regaining the navigation bar by sending setNavigationBarHidden:animated
to the current viewcontroller's navigation controller, as well as to the tabbarcontroller's navigationcontroller. I put this in response to the MPMoviePlayerDidExitFullscreenNotification
(it fires). No effect. If we rotate back to portrait, however, it's back instantly.
我的问题是:
- 为什么用户退出全屏显示时,顶部栏不返回?
- 我们如何找回顶部栏?
最诚挚的问候, 蒂莫
P.S.我将继续尝试此 SO帖子中所述的怪异之处.可能有关系.
P.S. I will proceed to experiment with the weirdnesses described in this SO post. Might be related.
推荐答案
我刚刚找到了一种更好的方法(从视图控制器返回时不会出现故障). 进入全屏模式时隐藏导航栏,然后在退出时再次显示它:
I just found a better way to to this (without the glitch when back from the view controller). Hiding the navigation bar when entering fullscreen and displaying it again on exit :
// In the view did load for example :
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerWillExitFullScreen:)
name:MPMoviePlayerWillExitFullscreenNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidEnterFullScreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil];
// And in the ViewController put these methods :
- (void) moviePlayerWillExitFullScreen:(id)sender {
[self.navigationController setNavigationBarHidden:NO animated:NO];
}
- (void)moviePlayerDidEnterFullScreen:(id)sender {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
这将使动画更加流畅.
这篇关于MPMoviePlayerController可以全屏退出,但顶部栏消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!