2012-11-21 26 views

Trả lời

1

Hãy thử this-

  1. Tạo lớp con (CustomNavigationController) của UINavigationController & sử dụng nó để thúc đẩy điều khiển tầm nhìn của bạn.
  2. Trong CustomNavigationController tạo UIBarButtonItem trong init hoặc trong viewDidLoad. Thêm target & action vào đó.
  3. Thực hiện UINavigationControllerDelegate đại biểu trong CustomNavigationController và đặt barButtonYouCreated làm mục nút thanh phải hoặc trái cho mỗi bộ điều khiển chế độ xem theo phương pháp đại biểu.

Sử dụng

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

hoặc

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

Bạn có thể sử dụng UINavigationControllerDelegate như sau:

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

Và trong phương pháp đại biểu này, bạn có thể kiểm tra thêm một barButtonItem để thanh điều hướng.

0

Bạn có thể tạo ra một thế giới UITabBarController trong UINavigationController có chứa bộ điều khiển đẩy bạn, sau đó làm cho bộ điều khiển đẩy bạn navigationbar ẩn

0

Hoặc thử sử dụng một loại UINavigationController, và tùy chỉnh các mục trở lại, vì vậy dù có bao nhiêu lần nó đẩy , chỉ cần đặt chế độ xem tương tự cho mục sau của navigationController. Một cái gì đó như:

@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]; 
} 
Các vấn đề liên quan