0

我已经从控件中获取导航栏并添加了一个右栏按钮,它也来自控件我的要求是我只想在视图出现时隐藏右栏按钮,并且我已经为右栏按钮编写了下拉操作。我在这个视图控制器中有一个称为列表视图控制器的额外视图控制器当我选择一个对象时我有 3 个对象然后将其推送到主视图控制器并且右栏按钮可见并且当我单击右栏按钮时选择对象将被添加到下拉列表中,任何人都可以帮助我。

[self loadMenu];
[self btn];


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


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

1 回答 1

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;

希望这可以帮助!

于 2013-07-30T07:09:20.470 回答