gpt4 book ai didi

iphone - MPMoviePlayerViewController 状态栏问题 iOS 8 特定

转载 作者:行者123 更新时间:2023-12-03 20:40:13 26 4
gpt4 key购买 nike

注意:在 iOS 8 中,状态栏在横向时会自动隐藏,在纵向时会自动返回(仅限 iPhone)。

为了在我的应用中显示视频,我使用了 XCDYouTubeKit,它是 MPMoviePlayerViewController 上的轻型包装器。

由于某些功能,我必须在应用程序中将 info.plist 文件中的“查看基于 Controller 的状态栏外观”设置为“否”。该应用程序工作正常,直到您不使用 XCDYouTubeKit(MPMoviePlayerViewController)。使用 XCDYouTubeKit 后,应用程序将失去上面“注意”中指定的功能,这意味着状态栏也开始以横向方式显示。

您可以在此处下载演示项目。

https://www.dropbox.com/s/yp5pkvf9evsl8wb/XCDYouTubeKit%20Demo.zip?dl=0

要体验此功能,您需要在 XCDYouTubeKit 演示中执行以下步骤:

  1. 在 info.plist 文件中设置“查看基于 Controller 的状态栏外观”改为“否”。
  2. 在 iOS 8 中打开应用并转到“全屏播放器”。
  3. 将方向从纵向更改为横向,反之亦然。您会发现状态栏在横向时隐藏,但在纵向时不隐藏。
  4. 现在点击“全屏播放”按钮(纵向模式)并让 View Controller 出现。
  5. 按“完成”按钮关闭视频(无论方向如何)。
  6. 将方向从纵向更改为横向,反之亦然。您会发现,无论设备方向如何,状态栏始终保持在那里。

请帮忙!!!

最佳答案

还要注意,哈什,你可以(有争议!)只使用一个类别!

对于整个应用

仅一次。我们在大批量生产应用程序(在 Objective-C 时代)中每次都这样做,没有任何问题,而且我在大批量客户项目中经常看到它。 ...所以..

1) 创建一个名为 UIViewController+HideStatusBar

的类别
@interface UIViewController (HideStatusBar)
@end
// the only practical approach for no-statusbar in iOS7,8+
@implementation UIViewController (HideStatusBar)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
-(BOOL)prefersStatusBarHidden {return YES;}
-(UIViewController *)childViewControllerForStatusBarHidden {return nil;}
#pragma clang diagnostic pop
@end

2)在你的plist中添加

<key>UIStatusBarHidden~ipad</key>
<true/>
// that is needed if you're covering iPad; do it always for consistency

3) 不要不要在plist中将“状态栏最初隐藏”设置为“YES”。

4) 不要不要改变 UIViewControllerBasedStatusBarAppearance。

扩展discussion .

关于iphone - MPMoviePlayerViewController 状态栏问题 iOS 8 特定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26167038/

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