簡體   English   中英

UINavigationViewController 中的 UIInterfaceOrientation

[英]UIInterfaceOrientation in UINavigationViewController

我在 UINavigionViewController 內的視圖中遇到自動旋轉問題,而 navigationViewcontroller 在 tabBarViewController 內。

我繼承了 tabBarViewController。 問題是界面方向在 tabViewController 內的第一個視圖上工作正常,但是每當我推送到另一個視圖時它都不起作用。

這是子類 tabBarController 中的代碼

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
    if([self.selectedViewController isKindOfClass:[UINavigationController class]]){
        return [[(UINavigationController*)self.selectedViewController visibleViewController] shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    } else {
        return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    }
}

您必須在選項卡欄中的所有視圖的視圖控制器中覆蓋 shouldAutorotateToInterfaceOrientation:。

如果視圖控制器的 shouldAutorotateToInterfaceOrientation: 返回 NO,則標簽欄不會旋轉,即使視圖在旋轉時隱藏。

您應該在UITabBarController內的UINavigationController內有一個UIViewController 旋轉由 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:在您的UIViewController中決定。 您需要為每個UIViewController覆蓋該方法以返回所需的值,即,如果您希望它旋轉,則為YES ,如果您不希望它旋轉,則為NO

您不應該在UINavigationControllerUITabBarController中覆蓋 shouldAutorotateToInterfaceOrientation shouldAutorotateToInterfaceOrientation:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM