Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma mark - Application Orientations
- /**
- * iPhone: rotate only full gallery view or while movie is being played
- * iPad: Lanscape only
- *
- * @param application
- * @param window
- *
- * @return the orientations
- */
- - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
- // Dont rotate for iPad. Allow to rotate if there is fullscreen video but while on iPhone or iPod,
- // only playback video in landscape - while leaving the app itself in portrait only.
- //
- //iPad behaviour
- if (INTERFACE_IS_IPAD)
- return UIInterfaceOrientationMaskLandscape;
- //iPhone behaviour
- NSUInteger orientations = UIInterfaceOrientationMaskAllButUpsideDown;
- UIWindow *keyWindow = window; //[UIApplication sharedApplication].keyWindow;
- if(keyWindow && keyWindow.rootViewController){
- UIViewController *presentedViewController = [keyWindow.rootViewController topmostViewController];
- //NSLog(@"PresentedViewController: %@", [presentedViewController class]);
- if ([self vcIsVideoPlayer:presentedViewController] ){
- orientations = UIInterfaceOrientationMaskAll;
- }
- else{
- if ([presentedViewController isKindOfClass:[UIActivityViewController class]] || [presentedViewController isKindOfClass:[UIAlertController class]]) {
- orientations = UIInterfaceOrientationMaskPortrait;
- }
- else{
- orientations = [presentedViewController supportedInterfaceOrientations];
- }
- }
- }
- return orientations;
- }
- - (BOOL)vcIsVideoPlayer:(UIViewController *)vc{
- static NSString * const VIDEO_CONTROLLER_CLASS_NAME_IOS7 = @"MPInlineVideoFullscreenViewController";
- static NSString * const VIDEO_CONTROLLER_CLASS_NAME_IOS8 = @"AVFullScreenViewController";
- static NSString * const VIDEO_CONTROLLER_CLASS_NAME_NATIVE = @"MPMoviePlayerViewController";
- NSString *className = vc ? NSStringFromClass([vc class]) : nil;
- return (
- [className isEqualToString:VIDEO_CONTROLLER_CLASS_NAME_NATIVE] ||
- [className isEqualToString:VIDEO_CONTROLLER_CLASS_NAME_IOS7] ||
- [className isEqualToString:VIDEO_CONTROLLER_CLASS_NAME_IOS8]
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement