首页 文章

Objective-c使用UIInterfaceOrientationMask来控制方向

提问于
浏览
1

我有一个带有4个viewcontrollers的应用程序 . 必须仅以横向模式呈现一个 . 其他3可以是风景或肖像 .

在我的部署信息区域,设备方向,我已选中颠倒,横向左侧和横向右侧 . 在Info.plist中,我有3个支持的界面方向:Landscape Left,Landscape Right和Portrait Top Home Button .

在我的视图控制器中我只想要风景我有: - (BOOL)shouldAutorotate {return YES; }

-(UIInterfaceOrientationMask) supportedInterfaceOrientations {
    return   UIInterfaceOrientationMaskLandscapeLeft+UIInterfaceOrientationMaskLandscapeRight;
}

在其他3个视图控制器中我有: - (BOOL)shouldAutorotate {return YES; }

-(UIInterfaceOrientationMask) supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}

使用所有这些设置:1)仅应在横向中的视图仅在横向中,因此这很好 . 2)其他3个视图可以横向左侧,横向右侧和纵向模式显示,按钮位于顶部 . 3)当我尝试在另一个纵向位置旋转屏幕时,它不会旋转 .

因此,我更改“部署”页面或“Info.plist”页面以包含未选中的第4个选项 . 结果是其他3个视图旋转正常,但横向模式视图现在旋转为纵向 .

我需要做什么才能获得我的第一个视图景观而另外3个以任何方式旋转?

1 回答

相关问题