2012-11-14 87 views
2

自iOS6以来,我意识到shouldAutorotateToInterfaceOrientation:方法已被弃用。我的大多数应用程序都希望用户能够旋转,目前在iOS6和iOS5中可以工作。但是,我有我只想成为一个portrait模式的看法,所以我增加了以下没有实际工作(在模拟器和设备测试):iOS6自动混淆并支持iOS5

// Tell the system what we support 
- (NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationPortrait; 
} 

// Tell the system It should autorotate 
- (BOOL) shouldAutorotate { 
    return NO; 
} 

// Tell the system which initial orientation we want to have 
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return UIInterfaceOrientationPortrait; 
} 

为什么没有这个代码防止我的情态从旋转? 我还能如何支持iOS5方法以及iOS6方法,而不会导致iOS5用户崩溃?

+0

模态是由家长提出的。如果有条件地停止父项的旋转,会发生什么 –

+0

不,将它们放在父'viewController'中并不会停止旋转。 –

+0

如果实现'shouldAutorotateToInterfaceOrientation:'它不会导致它在iOS 5上崩溃。只需实现'shouldAutorotateToInterfaceOrientation:'以及iOS 6方法。 – mattjgalloway

回答

0

你错过了,但此行您-(void)viewDidLoad方法

[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"UIApplicationSupportedInterfaceOrientationsIsEnabled"]; 

里面我希望这可以帮助你

+0

我没有看到任何证据表明此线有任何影响。 –