In iOS6, shouldAutorotateToInterfaceOrientation
is deprecated. I tried to use supportedInterfaceOrientations
and shouldAutorotate
to make app working correctly for autorotation but failed.
this ViewController I don’t want to rotate, but it doesn't work.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Any ideas? Thanks for any help in advance!
If you are using a Tab Bar Controller instead of a Navigation Controller as your root controller, you'll need to similarly subclass UITabBarController.
Also the syntax will be different. I used the following with success. I then used the above examples with success on the view controllers I wanted to override. In my case I wanted the main screen to not rotate but I had a FAQ Screen with Movies that I naturally wanted to enable landscape view. Worked perfectly! Just note the syntax change to self.modalViewController (you'll get a compiler warning if you try to use the syntax for a navigation controller.) Hope this helps!
Figured it out.
1) subclassed UINavigationController (the top viewcontroller of the hierarchy will take control of the orientation.) did set it as self.window.rootViewController.
2) if you don't want view controller rotate
3) if you want it to be able to rotate
BTW , According to your needs ,another related method :