my project have UITabbar, UınavigationBar and UIViewContoller.
-UITabbar
—UINavigationController
—UIViewController
Question: how can i do landscape disable just one viewController? i want to only portrait view but for just one view.
disable autorotate on a single UIViewController in iOS6
Add this to your app delegate
- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[window.rootViewController presentedViewController] isKindOfClass:[YourViewController class]]) return UIInterfaceOrientationMaskPortrait; else return UIInterfaceOrientationMaskAllButUpsideDown; }
EDIT 2
I recently found out about this, and it has been working perfectly for me. Add this code to your view controller
- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; }
And in your viewWillAppear
add
- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; ///Disable orientation changes NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait]; [[UIDevice currentDevice] setValue:value forKey:@"orientation"]; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.