MTA*_*MTA 3 iphone xcode objective-c ios
我的应用程序中有UiNavigationController.我希望只有一个屏幕可以旋转,所以我放入这个类:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return YES;
}
-(BOOL)shouldAutorotate {
return YES;
}
-(NSInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
Run Code Online (Sandbox Code Playgroud)
但发生的问题是在ecery屏幕上应用程序旋转发生.我怎么能禁用它?
use*_*524 10
对于iOS 6,我在我的应用程序中使用以下代码,它允许您单独指定每个viewcontroller的旋转:
AppDelegate.m -
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{NSUInteger orientations =UIInterfaceOrientationMaskAllButUpsideDown;
if(self.window.rootViewController){
UIViewController *presentedViewController = [[(UINavigationController *)self.window.rootViewController viewControllers] lastObject];
orientations = [presentedViewController supportedInterfaceOrientations];
}
return orientations;
}
Run Code Online (Sandbox Code Playgroud)
ViewController.m -
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
最初的代码信用我相信去Ray Wenderlich"iOS 6 by Tutorials"一书.Ray Wenderlich网站
| 归档时间: |
|
| 查看次数: |
4378 次 |
| 最近记录: |