0

我一直在努力解決這個問題好幾天。在我的應用程序中,我在內部具有帶UINavigationViewControllers的標籤欄控制器。我希望每個導航控制器中的每個導航欄看起來都完全相同,具體取決於用戶操作和應用程序狀態。 例如:如果用戶在第一個視圖控制器中登錄到我的應用程序,則應用程序會在導航欄中設置其名稱並將導航欄設置爲登錄狀態。然後,當用戶選擇其他選項卡項目時,我想將此導航欄的此登錄狀態從第一個視圖控制器設置爲其他視圖控制器。我試過使用單例,但沒有效果。每個標籤中的導航欄的一個實例

回答

0

好像你必須做兩件事情:

  1. 將當前設置,同時初始化的UIViewController
  2. 更新狀態後,所有啓動控制器改變

以1: 創建一個類與

@interface UIViewController (UINavigationController) 

- (UINavigationController*)wrapWithNavigationController; 

@end 

@implementation UIViewController (UINavigationController) 

- (UINavigationController*)wrapWithNavigationController 
{ 
    UINavigationController* navigationController = [[UINavigationController alloc] initWithRootViewController:self]; 

    // your customizations 
    navigationController.navigationBar.barStyle = UIBarStyleBlack; 
    [...] 

    return [navigationController autorelease]; 
} 

@end 

你可以ca例如,它可以是UIViewControllerAdditions

以2:

使用NSNotificationCenter更新:)

0

你真的有多個UINavigationControllers,或者你只是想用navigationBar在每個標籤相同的作用和功能?

如果你只是想有吧,你也可以使用一個UINavigationController將您的應用rootViewController然後UITabBarController爲您UINavigationControllerchildViewController

相關問題