2012-11-21 53 views

回答

1

嘗試的UINavigationController &這 -

  1. 創建子類(CustomNavigationController)用它來把你的視圖控制器。
  2. CustomNavigationController創建UIBarButtonIteminit或在viewDidLoad。加上target & action就可以了。
  3. 執行UINavigationControllerDelegate代表CustomNavigationController代表作爲委託方法中每個視圖控制器的右或左欄按鈕項目。

使用

- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated { 
    viewController.navigationItem.leftBarButtonItem = barButtonYouCreated; 
} 

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
0

您可以按以下使用UINavigationControllerDelegate

- (void)navigationController:(UINavigationController *)navigationController 
     willShowViewController:(UIViewController *)viewController animated:(BOOL)animated 

而在這個委託的方法,你可以檢查到barButtonItem增加導航欄。

0

您可以創建在UINavigationController全球UITabBarController包含您的推控制器,然後進行推控制器navigationbar隱藏

0

或者嘗試使用一個UINavigationController類別,以及自定義返回項目,所以不管它有多少次推,只需爲navigationController的後臺項目設置相同的視圖即可。 類似於:

@implementation UIViewController (CustomNavigation) 

- (void)setLeftBarButtonItem:(UIButton*)leftview 
{  
    UIBarButtonItem *customItem = [[[UIBarButtonItem alloc] initWithCustomView:leftview] autorelease]; 
    self.navigationItem.leftBarButtonItem = customItem; 
    [(UIButton*)self.navigationItem.leftBarButtonItem.customView addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside]; 
} 
相關問題