gpt4 book ai didi

iphone - 退出电影播放器​​全屏会导致 navigationController 导航栏移到状态栏后面

转载 作者:行者123 更新时间:2023-12-03 19:30:45 30 4
gpt4 key购买 nike

我在 ViewController 上添加了一个 MPMoviePlayerController View 作为 subview 。

我正在使用layoutSubviews 在方向更改期间调整 subview 的大小。

当我以全屏方式播放电影,并且仍处于全屏状态时,旋转手机,有时当我退出全屏时,我的导航栏“隐藏”在状态栏下方的一半,就好像两者的起源相同状态栏位于顶部。

我想知道我是否做错了什么...有人可以帮忙吗?

谢谢!

最佳答案

不要更改您的导航栏的框架,请阅读以下 Apple 文档:

The navigation controller manages the creation, configuration, and display of the navigation bar and optional navigation toolbar. It is permissible to customize the navigation bar’s appearance-related properties but you must never change its frame, bounds, or alpha values directly. If you subclass UINavigationBar, you must initialize your navigation controller using the initWithNavigationBarClass:toolbarClass: method. To hide or show the navigation bar, use the navigationBarHidden property or setNavigationBarHidden:animated: method

https://developer.apple.com/library/ios/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html

现在我这样做了,效果非常好:
1)在 View Controller 的入口点将您自己添加为电影播放器​​状态的观察者

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerChangedState) name:@"UIMoviePlayerControllerWillExitFullscreenNotification" object:nil];

2)响应通知:

// run this method on the main thread
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
[self.navigationController setNavigationBarHidden:YES];
[self.navigationController setNavigationBarHidden:NO animated:YES];

注意:此代码适用于 iOS 7,我尚未针对旧版本的 iOS 进行测试。

关于iphone - 退出电影播放器​​全屏会导致 navigationController 导航栏移到状态栏后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5188388/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com