【发布时间】:2012-06-23 10:36:33
【问题描述】:
是的,我知道这个问题已经被问过很多次了,但我找不到任何可以进一步帮助我的东西。
使用带有 3 个视图控制器的导航控制器,我需要保留以前屏幕中的数据,因此我不使用 segues,而是像这样:
// When button is pressed
- (IBAction)changeView:(id)sender {
NSLog(@"Skipped connection screen");
ViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"SecondView"];
[self.navigationController pushViewController:vc animated:YES];
} 其中 SecondView 是应该出现的视图控制器的标识符。因为我只希望旋转在水平右侧,所以我在我拥有的每个 .m 文件的顶部添加了这段代码的 sn-p 代码:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
在我的 project-Info.plist 中,我添加了 Initial interface orientation = Landscape (right home button,在我的项目设置中,我只添加了对这个方向的支持。
问题是,当我在 iPhone 上运行时,如果我以任何一种方式转动手机,方向都会从横向改变。当我试图把它转回来时,它就不会了。我想确保这个应用程序永远能够从横向旋转。
有什么建议吗?非常感谢您提前。
【问题讨论】:
-
请看我下面的答案,如果你有任何问题,请告诉我。
标签: iphone ios xcode uiviewcontroller uinavigationcontroller