开发者

How to disable rightBarButtonItem

开发者 https://www.devze.com 2022-12-12 04:24 出处:网络
How can I enable/disable navigationItem.rightBarButton item? I am calling the following code at -viewDidLoad but it does nothing.

How can I enable/disable navigationItem.rightBarButton item? I am calling the following code at -viewDidLoad but it does nothing.

self.navigationItem.rightBarButtonItem = 
      [[[UIBarButton开发者_如何学编程Item alloc]
            initWithTitle:@"Flow"
            style:UIBarButtonItemStyleDone
            target:self  action:@selector(flowWithMe:)] autorelease];

self.navigationItem.rightBarButtonItem.enabled = NO;

I want to enable right Bar Button only on a particular action.


You can set the rightBarButtonItem to nil until the point where you need to enable it.


I found the problem, i was reenabling the button on - (void)textFieldDidBeginEditing:(UITextField *)textField

and this was the only text field on the view and on ViewDidLoad this was becoming the first responder so after ViewDidLoad, this function was getting called and right bar button was re-enabled.

0

精彩评论

暂无评论...
验证码 换一张
取 消