我有一个UIWebView包含在UIViewController这是UINavigationController的后代。它看起来像这样:允许唯一肖像应用程序的风景视频
应用程序是唯一的肖像。当我播放视频时,我希望用户能够旋转设备并以横向模式查看视频。我用这个代码,允许它:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
id presentedViewController = [self topMostController];
NSString *className = presentedViewController ? NSStringFromClass([presentedViewController class]) : nil;
if ([className isEqualToString:@"MPInlineVideoFullscreenViewController"] ||
[className isEqualToString:@"MPMoviePlayerViewController"] ||
[className isEqualToString:@"AVFullScreenViewController"]) {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
return UIInterfaceOrientationMaskPortrait;
}
- (UIViewController *)topMostController {
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
return topController;
}
然后在我的UINavigationController(所以当视频结束的观点并没有在景观呈现,但只有在人像):
- (BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
一切完美:
但随后的视频播放完毕(或用户点击“完成”)和屏幕返回底层来看,这是发生了什么:
正如你所看到的,导航栏,状态栏下滑动。 此外,我在日志中收到很多自动布局错误:http://pastebin.com/09xHzmgJ
有关如何解决此问题的任何想法?
什么是你的项目的设置(代码之外?) – 2015-08-18 20:58:29
@entropid你有没有为此打开一个雷达?在iOS 10上仍然存在问题... – 2017-01-10 16:59:50