2013-02-05 15 views
1

目前我只有在iPhone应用程序中的肖像模式。我想在应用程序中允许一个控制器的横向模式,但不幸的是我无法使其工作。iPhone应用程序风景模式不起作用

我在plist文件有以下设置:

<array> 
    <string>UIInterfaceOrientationPortrait</string> 
    <string>UIInterfaceOrientationLandscapeRight</string> 
    <string>UIInterfaceOrientationLandscapeLeft</string> 
</array> 

而且我实现我的控制器来使用这些方法:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

-(BOOL)shouldAutorotate 
{ 
    return YES; 
} 

我使用导航控制器的应用程序,所以我意识到,这可能是问题。我分类UINavigationController并再次以上述相同的方式实施shouldAutorotateToInterfaceOrientation,supportedInterfaceOrientationsshouldAutorotate。当然,我使用subclassed导航控制器来显示控制器应该有旋转能力。我也尝试按类别覆盖导航控制器的方法,但它也不起作用。

我从一开始就不在应用程序上工作,我继承了代码。如果有可能如何限制全球景观这可能是我的情况。为了测试我使用iPhone 6.0模拟器,但我的部署目标是5.0。我感谢任何提示/帮助。

+0

http:// stackoverflow。com/questions/12600082/set-orientation-to-landscape-mode-in-xcode-4-5-gm-ios-6 – Rushabh

回答

2

iOS6的还需要您设置RootViewController的为您的窗口,而不是添加控制器的视图作为一个子视图。

如果你正在做的事情是这样的:

[window addSubview:someController.view]; 

,那么你可以尝试将其更改为这样:

[window setRootViewController:someController]; 

也期待在这个link。对于iOS6的,苹果推出了这两种方法:

supportedInter 
  1. faceOrientations:
  2. shouldAutorotate

希望它能帮助。

Shumais Ul Haq

+0

感谢日志,这正是问题 – Michal

+0

欢迎:) –

0
  1. 转到目标窗口。
  2. 单击摘要选项卡。
  3. iPhone/iPad部署信息 - >根据您的要求设置iPhone支持的iPhone & iPad的接口方向。请参阅以下图片获取更多参考。

enter image description here

+0

感谢Girish,但这并不能帮助我,我已经设置了所有接口方向,除了倒置 - 与截图 – Michal

+0

@Michal完全相同,然后按照岩石共享的链接。 – Girish

1

试试这个控制器上的youwant给横向

// override to allow orientations other than the default portrait orientation 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    // return YES for supported orientations 
    return UIInterfaceOrientationIsLandscape(interfaceOrientation); // support only landscape 
} 
相关问题