本文介绍了以编程方式更改iPhone中的设备方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有基于导航的应用程序,当我点击根视图中的任何行时,下一个视图应该以横向模式进入。
I have navigation based app, when I click on any row in root view, the next view should come in Landscape mode.
我无法找到实现此方法的正确方法。我试过的是:
I am not able to find a proper way to implement this. What I tried is:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
但这不起作用。视图应仅在横向模式下打开(而不是在用户旋转时)。谁能帮我。谢谢
But this is not working. The view should open only in Landscape mode (not when user rotate it). Can any one help me. Thanks
推荐答案
我的沙盒应用程序:
解决方案很简单:
:
BOOL rotated;
实现中(m文件):
1.重写
in implementation (m file):1. rewrite
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return rotated;
}
2来电[自我设置]
2 call [self setup]
-(void) setup {
rotated = YES;
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationLandscapeLeft];
rotated = NO;
}
这篇关于以编程方式更改iPhone中的设备方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!