我有一个分割视图控制器,支持横向和纵向模式 . 当详细视图控制器在某个视图上时,我禁用纵向并仅允许横向 . 但是,如果用户离开该特定视图,将设备旋转为纵向,然后返回到该特定视图,则它仍处于纵向状态 . 我需要它自动旋转回景观 . 以下是我正在使用的内容 . 这些方法都是从我的子类UISplitViewController中调用的,因此方向可以取决于视图控制器 .
#pragma mark - Orientation
- (BOOL)shouldAutorotate
{
// Allow view controller to rotate between landscapes
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
// Return supported interface orientation
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
// Return preferred orientation
return UIInterfaceOrientationLandscapeLeft;
}
1 回答