How to disable UIBarButtonItem?

后端 未结 4 2079
清酒与你
清酒与你 2020-12-30 18:53

I have a UIBarButtonItem that just doesn\'t want to get disabled. Short version: when I call

[myBarButtonItem setEnabled:NO];

Nothing happe

4条回答
  •  梦毁少年i
    2020-12-30 19:32

    You can disable the left navigation button from inside an UIViewController like this, without using any IBOutlet:

    self.navigationItem.leftBarButtonItem.enabled = NO;
    

    To disable the right navigation button:

    self.navigationItem.rightBarButtonItem.enabled = NO;
    

    Swift3

    self.navigationItem.rightBarButtonItem?.isEnabled = false
    

提交回复
热议问题