2013-07-30 169 views
0

我已經從控件採取了導航欄,並添加了一個正確的酒吧按鈕,它也從控件採取我的要求是我只想隱藏正確的酒吧按鈕,當視圖將出現,我寫了下拉行動右欄按鈕。我有一個額外的視圖控制器稱爲列表視圖控制器在這個視圖控制器我有3個對象,當我選擇一個對象,然後它是推到主視圖控制器和右欄按鈕是可見的,當我點擊右欄選擇按鈕對象是要添加在下拉列表中任何一個可以幫助我。導航欄邏輯實現

[self loadMenu]; 
[self btn]; 


self. navigationItem.title = @"sample"; 
[super viewDidLoad]; 


appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
self.navigationController.navigationBar.barStyle = UIBarStyleBlack; 

回答

0

我對你問的有點糊塗,但我相信,你應該做的是

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; 

希望這有助於!

+0

非常感謝你爲我的repsonse其實我有2 viewcontrol1像viewcontrol1和2。在視圖中控制一個我有一個正確的按鈕,當啓動我的應用程序正確的酒吧按鈕應該隱藏。第二件事是在視圖中control2我有三個對象(像圖像行中的項目)在列表中時,我選擇一個圖像它將被推到視圖控制器1和正確的酒吧按鈕應該啓用 –

+0

不客氣,但你想要什麼當你推視圖時,你使用[self.navigationController pushViewController:(UIViewController)animated:YES];當你想回去只是做popViewController – user2277872

+0

self.navigationController.navigationItem.rightBarButtonItem.enabled = NO;我申請這個,但不工作 –