对于 IOS 5 和 5.1:
尝试(BOOL)shouldAutorotateToInterfaceOrientation
在您的视图控制器中设置,它对我有用。
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
return toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
如果您使用情节提要,您还可以将初始视图控制器和其他视图控制器设置为横向模式:
对于 IOS 6:
你 (NSInteger)supportedInterfaceOrientations
应该是(NSUInteger)
,我不确定虽然我从不使用它。
// Only used by iOS 6 and newer.
- (BOOL)shouldAutorotate
{
//returns true if want to allow orientation change
return TRUE;
}
- (NSUInteger)supportedInterfaceOrientations
{
//decide number of origination to supported by Viewcontroller.
return return UIInterfaceOrientationMaskLandscape;
}