2013-02-05 22 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 
} 
相關問題