如何在导航控制器中以横向模式推动视图控制器,而其他在iPhone ios 8中的纵向中

时间:2014-09-29 12:10:35

标签: ios8 orientation

如果我使用下面的代码提供该控制器,那么它的工作正常&它处于Landscaspe模式但是如果我按下它而不是呈现该控制器,那么它在纵向模式下出现。

 AppDelegate *app= (AppDelegate *)[[UIApplication sharedApplication] delegate];

app.islandscape=YES;//For Landscape Mode

iPhoneSignatureScreenViewController *r=[[iPhoneSignatureScreenViewController alloc]init];
[self presentViewController:r animated:YES completion:nil];
[self dismissViewControllerAnimated:YES completion:nil];

我使用过自定义导航控制器子类& bool变量以保持哪个控制器应该在Portrait&在Landscape.For其他控制器岛景设置为NO。

在我的自定义导航控制器类中,我实现了: -

- (BOOL)shouldAutorotate
{
 return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
AppDelegate *appdelgate= (AppDelegate *)[[UIApplication sharedApplication] delegate];

if (appdelgate.islandscape) {

    return UIInterfaceOrientationMaskLandscape;

}
return UIInterfaceOrientationMaskPortrait;

}

1 个答案:

答案 0 :(得分:1)

在导航控制器推送中,我没有运气这么做。 + attemptRotationToDeviceOrientation方法听起来应该有所帮助,但对我来说并非如此。以与当前顶视图不同的方向可靠地呈现视图的唯一方法是模态呈现。