【发布时间】:2014-04-24 20:48:36
【问题描述】:
我有十多个处于纵向模式的 ViewController,但无论设备的方向如何,我都需要强制一个处于横向模式。
【问题讨论】:
标签: ios objective-c
我有十多个处于纵向模式的 ViewController,但无论设备的方向如何,我都需要强制一个处于横向模式。
【问题讨论】:
标签: ios objective-c
解决办法如下:
1) 将 LandscapeViewController 嵌入到子类 NavigationController 中,并使用 modal segue 从 PortraitViewController 连接它。
2) 子类 UINavigationController
LandscapeNavigationController.m
-(BOOL)shouldAutorotate
{
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
3) 不要忘记关闭你的模态 VC(在这种情况下是从我的 Bar Buttom Item Action 开始)
- (IBAction)goBack:(id)sender
{
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
【讨论】: