2010-01-19 26 views
2

另一个横向模式问题。iPhone SDK:强制应用的单个部分的横向模式

我们都看到了

[UIApplication的sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight动画:NO];

废话。我无法在模拟器或设备上使用此功能。

我得到的是这样的:

http://i47.tinypic.com/zl9egh.png

,当我真的想这样:

http://i45.tinypic.com/xms6cm.png

正如你可能可以告诉,它的翻转手机,但它并没有意识到它已被翻转。

我看到的隐藏方法

[[的UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];

但我需要这个应用程序在应用程序商店,我不知道他们是否会打击。

有没有人有任何想法如何得到这该死的事情摆正自己?

回答

2

理想的情况下你的视图控制器应该实现:

- (BOOL)shouldAutorotateToInterfaceOrientation: 
         (UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 
       interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

然后该视图控制器只允许方向是横向放置的一个。

除非您有一个相当复杂的视图层次结构,它使用标签栏控制器,否则这应该会导致视图在被推送时旋转。

如果不工作,你可以尝试:

[[UIDevice currentDevice] performSelector: 
           @selector(setOrientation:) 
          withObject:(id)UIInterfaceOrientationLandscapeRight]; 

我已经在使用此代码AppStore的应用程序,因为在我的情况我有意见的阶层,保持一个我需要的只能从工作中景观。

+1

这并不解决erroniously翻转回到纵向视图的一个问题。然而,我的主要问题是初始负载。当它被按下时,它将以纵向模式结束。 我把状态栏代码放在我的目标视图控制器的viewDidLoad中......我应该把它放在其他地方吗? – 2010-01-19 17:44:19

相关问题