How can I make the landscape disable only one viewController iOS

My project has UITabbar, UınavigationBar and UIViewContoller.

-UITabbarUINavigationControllerUIViewController

Question: how can I make a landscape disable only one viewController? I want only a portrait look, but only for one look.

+4
source share
1 answer

disable autorotation on one UIViewController in iOS6

Add this to your application delegate

- (NSUInteger) application:(UIApplication *)application     supportedInterfaceOrientationsForWindow:(UIWindow *)window {

if ([[window.rootViewController presentedViewController] isKindOfClass:[YourViewController class]])
    return UIInterfaceOrientationMaskPortrait;
else
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

Strike> EDIT 2

I recently found out about this and it works great for me. Add this code to your controller.

- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}

And in your viewWillAppearadd

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    ///Disable orientation changes
    NSNumber *value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
+4
source

All Articles