0

在我的應用程序中,我有一個UITabBarController,其中包含3個UINavigationController。我可以凍結任何UIViewController的方向。爲此,我實施了UITabBarControllerUINavigationController。但是當我從景觀中的另一個推動UIViewController時會發生問題。新推送的UIViewController應該是縱向的,但它仍然在橫向。我知道問題可能不清楚,所以我附上scrrenshots。視圖控制器的固定方向

讓我們考慮它的VC-A。

enter image description here

從VC-A按編輯進入到這個VC-B。 VC-B是:

enter image description here

該VC-B應該總是肖像。 VC-A可以是橫向或縱向。當VC-A是在景觀和我按編輯的VC-B推和VC-B來在橫向模式下,雖然我實現了在VC-B這些方法:

-(BOOL)shouldAutorotate { 
    return UIInterfaceOrientationMaskPortrait; 
} 

-(NSUInteger)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return UIInterfaceOrientationPortrait; 
} 

回答

0

shouldAutorotate需要返回BOOL不在屏蔽,所以代碼應該是

-(BOOL)shouldAutorotate { 
    return YES; 
} 
+0

那不是問題所在。 – Rashad