1

How can I prevent the rotation on one UIViewController by code ? in more words I want to prevent rotation for one UIViewController not for all

Mhmd Backer Shehadi
  • 559
  • 1
  • 12
  • 30
  • possible duplicate of [disable autorotate on a single UIViewController in iOS6](http://stackoverflow.com/questions/17370806/disable-autorotate-on-a-single-uiviewcontroller-in-ios6) – CRDave Apr 03 '14 at 07:45

2 Answers2

1

You need to subclass the view controller, and then return NO from shouldAutoRotate

-(BOOL) shouldAutorotate {
    return NO;
}

https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instm/UIViewController/shouldAutorotate

1

In Your view controller

-(BOOL)shouldAutorotate {

return YES;

}

-(NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskPortrait;

}