Created
June 8, 2014 08:29
-
-
Save kazuph/394cdf5a27d6c0be6346 to your computer and use it in GitHub Desktop.
縦対応(Portrait)しかしていないアプリでUIWebViewで動画を再生したときに横回転(Landscape)するようにする ref: http://qiita.com/kazuph/items/78cbb007be84308ce627
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 回転時に呼ばれる | |
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { | |
NSString *className = NSStringFromClass([window class]); | |
// ネストしているViewがMPFullscreenWindowやMPInlineVideoFullscreenViewControllerである場合があるので確認する | |
if ([((UITabBarController *)window.rootViewController) respondsToSelector:@selector(presentedViewController)]) { | |
className = NSStringFromClass([((UITabBarController *)window.rootViewController).presentedViewController class]); | |
} | |
// MP*FullscreenWindowなどがYouTube再生時のViewの名称なので | |
// そのときは全部の回転を許可する | |
if ([className isEqualToString:@"MPFullscreenWindow"] || [className isEqualToString:@"MPInlineVideoFullscreenViewController"]) { | |
return UIInterfaceOrientationMaskAll; | |
} else { | |
return UIInterfaceOrientationMaskPortrait; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment