我正在研究仅支持横向定位的iPad应用程序,我想允许一些呈现的视图控制器支持所有方向而不改变呈现视图控制器的方向.我支持
Xcode设置中的所有方向,除了颠倒.
我用来呈现视图控制器的代码
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"VC"]; vc.modalPresentationStyle = UIModalPresentationFormSheet; [self presentViewController:vc animated:YES completion:nil];
- (UIInterfaceOrientationMask)supportedInterfaceOrientations { return UIInterfaceOrientationMaskAll; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ return YES; }
你管应用程序在播放视频时提供相同的功能,任何想法它是如何工作的?
任何帮助都会感谢,谢谢.
解决方法
AppDelegate.m
- (UIInterfaceOrientationMask)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if(_isAllModes) return UIInterfaceOrientationMaskAll; else return UIInterfaceOrientationMaskPortrait; }
你的ViewController.回转:
[(AppDelegate*)([UIApplication sharedApplication].delegate) setIsAllModes:YES]; NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"];