0

在我的應用程序中,我得到了2 UIViewControllers,第一個是UINavigationController中的根控制器,第二個是通過推向UINavigationController's堆棧調用第一個。UINavigationController中的UIInterfaceOrientation

所以第一個視圖應該只是縱向,第二個視圖應該支持所有的方向。

我在第一這段代碼中寫道:

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{ 
    return toInterfaceOrientation == UIInterfaceOrientationPortrait; 
} 

但它仍然旋轉至所有方向。爲什麼?

+0

嘗試使用新的iOS SDK 6.0自轉方法:'shouldAutorotate','supportedInterfaceOrientations','preferredInterfaceOrientationForPresentation' – George 2013-04-23 09:01:01

+0

@George仍然一無所獲(( – 2013-04-23 09:05:59

回答

0

我沒有使用uinavigationcontroller,而是使用presentmodalviewcontroller。這使我可以使用不同的方向管理。

0

我可以知道你使用的是什麼IOS版本嗎?此方法已用於IOS 6

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation 

請檢查下面的網址表決的答案是一些你可能會尋找

UITabBarController Rotation Issues in ios 6

0

最好的辦法是改變支撐取向在APP摘要只有一個你喜歡的(縱向)。

enter image description here

然後你就可以處理其他頁面定向委託方法。

-(BOOL)shouldAutorotate{ 
return YES; 

}

- (NSInteger的)supportedInterfaceOrientations { NSInteger的掩模= 0; if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeRight]) mask | = UIInterfaceOrientationMaskLandscapeRight; ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationLandscapeLeft]) mask | = UIInterfaceOrientationMaskLandscapeLeft; if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait]) mask | = UIInterfaceOrientationMaskPortrait; ([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortraitUpsideDown]) mask | = UIInterfaceOrientationMaskPortraitUpsideDown; return mask; }

+0

如果我只選擇在總結縱向,沒有旋轉(( – 2013-04-23 11:19:51

+0

這是使用方法。如果您只在應用程序摘要中設置縱向模式,應用程序將以縱向模式啓動,然後您可以處理任何視圖控制器中的方向更改,並且它將相應地工作。如果您在設備中嘗試,您的方向鎖定被關閉 – Prav 2013-04-23 11:29:04

+0

您是否也可以檢查是否正在對狀態欄方向進行任何更改? – Prav 2013-04-24 09:24:43

相關問題