Skip to content

Instantly share code, notes, and snippets.

@kazuph
Created June 8, 2014 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazuph/394cdf5a27d6c0be6346 to your computer and use it in GitHub Desktop.
Save kazuph/394cdf5a27d6c0be6346 to your computer and use it in GitHub Desktop.
縦対応(Portrait)しかしていないアプリでUIWebViewで動画を再生したときに横回転(Landscape)するようにする ref: http://qiita.com/kazuph/items/78cbb007be84308ce627
// 回転時に呼ばれる
- (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