问题
On the initial view of my app I want the interface to be portrait only but on the view controllers after that it can be any orientation. I tried this code to lock it but it doesn't work and the view can still rotate:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
回答1:
The reason that code is not working is most likely because you are running iOS 6. Try this code instead:
- (BOOL)shouldAutorotate {
return NO;
}
来源:https://stackoverflow.com/questions/12994990/locking-interface-orientation