我从控件中取出了导航栏,并添加了一个右键控制按钮,它也是从控件中取出的,我的要求是我只想隐藏右侧栏按钮,当视图出现时,我已经为右栏按钮写了下拉动作。我有一个额外的视图控制器称为列表视图控制器在这个视图控制器中我有3个对象当我选择一个对象然后它是推到主视图控制器和右栏按钮是可见的当我点击右栏按钮选中对象是要添加到下拉列表中可以任何人帮助我。
[self loadMenu];
[self btn];
self. navigationItem.title = @"sample";
[super viewDidLoad];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
答案 0 :(得分: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;
希望这有帮助!