Search code examples
ioscocoa-touchinterface-orientation

iOS: How can I disable autorotate in iOS 8.3.? none of the solutions I found online works


I'm trying to enforce portrait view of my app on iOS. It should be a simple thing but none of the solutions I found online seem to work. Here is the segment of code in my view controller:

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

    [ [ UIDevice currentDevice ] setValue:@( 1 ) forKey:@"orientation" ];
}

-(BOOL) shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation {
    return NO;
}

- (BOOL)shouldAutorotate {
    return NO;
}

-(NSUInteger)supportedInterfaceOrientations {
//  return UIInterfaceOrientationMaskPortrait;   //tried both
    return UIInterfaceOrientationPortrait;
}

It's an union of several solutions / posts I found online, and my app still "rotates like a charm". Is there something obvious that I'm missing? I'm developing on Xcode 6.3 for iOS 8.3.

Thanks!


Solution

  • If you want to enforce portrait orientation across your entire app just set supported interface orientations on your "Deployment info" section of the project's "General" target settings, here: enter image description here