我對你問的有點糊塗,但我相信,你應該做的是
self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
這將隱藏的按鈕,因爲它被設置爲啓用不集....
所以,從一個視圖到另一個,只是做
[navController pushViewController:viewController animatedYES];
和倒退從這一觀點做
[navController popViewControllerAnimated:YES];
現在乾脆添加:
// creating UIViewController objects for reference later
View1 *view1 = [[View1 alloc] init];
View2 *view2 = [[View2 alloc] init];
// you are setting the view1 right navigation button in the view1 viewDidLoad
self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;
// now you are pushing to second view
[navController pushViewController:view2 animated:YES];
// now, in the view2 class, where you get the image that sends the
// user back to view 1, just do
[view2.navController popViewControllerAnimated:YES];
// and then wherever you do the pop as shown above, you need to set the
// view1 right bar button to enabled
view1.navigationController.navigationItem.rightBarButtonItem.enabled = YES;
希望這有助於!
非常感謝你爲我的repsonse其實我有2 viewcontrol1像viewcontrol1和2。在視圖中控制一個我有一個正確的按鈕,當啓動我的應用程序正確的酒吧按鈕應該隱藏。第二件事是在視圖中control2我有三個對象(像圖像行中的項目)在列表中時,我選擇一個圖像它將被推到視圖控制器1和正確的酒吧按鈕應該啓用 –
不客氣,但你想要什麼當你推視圖時,你使用[self.navigationController pushViewController:(UIViewController)animated:YES];當你想回去只是做popViewController – user2277872
self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;我申請這個,但不工作 –