开发者

Hide a UIBarButtonItem when in edit mode

开发者 https://www.devze.com 2023-01-06 16:23 出处:网络
I have a UINavigationController with a UITableViewController which has and two UIBarButtonItems: - (void)viewDidLoad {

I have a UINavigationController with a UITableViewController which has and two UIBarButtonItems:

- (void)viewDidLoad {
    [super viewDidLoad];


    self.navigationItem.leftBarButtonItem = self.editButtonItem;
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showSubscribeSheet:)];

    self.navigationController.navigationBar.tintColor = [UIColor brownColor];
}

I want to hide self.navigationItem.rightBarButtonItem when the UITableView is in edit mode. What way can I do this? Thanks.


I do not use 开发者_如何转开发nibs.


Just set it to nil to hide it

self.navigationItem.rightBarButtonItem = nil ;


In your selector of the UIBarButtonItem just check the [self.tableView isEditing] where this will indicate that the table view is in the editing mode if it returns true. Else it should return false.


Override the setEditing method:

-(void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing...]
    //custom code here
}
0

精彩评论

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