我有一個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