问题
I created an application with a TabBarController using IB who have 4 TabBarItems and so display 4 differents ViewControllers. To allow a landscape orientation I must add this code in all of my ViewController:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}
The problem is I don't want for example the secondViewController to autorotate, How can I do that? Because everytime I delete the code above in one of my ViewController, every ViewControllers not rotate anymore.
Thanks
回答1:
Leave the code in there, but you'll want to do one of two things:
- Disable the non-rotatable tab when showing landscape view OR
- In the viewWillAppear or viewDidAppear for that tab, force rotation to portrait.
eg:
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES]
来源:https://stackoverflow.com/questions/2442385/uitabbarcontroller-autorotation