标签:
- (void)showEdit {
if (不符合显示条件) {
self.navigationItem.rightBarButtonItem.customView.hidden = YES;
//[self.navigationItem.rightBarButtonItem.customView setAlpha:0.0];
} else{
self.navigationItem.rightBarButtonItem.customView.hidden = NO;
//[self.navigationItem.rightBarButtonItem.customView setAlpha:1.0];
}
}
经过亲自尝试,该种方法并不能实现隐藏和显示功能,于是,尝试用下面这种方法成功解决了问题
- (void)showEdit {
if (符合显示条件) {
if (self.navigationItem.rightBarButtonItem == nil) {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"编辑" style:UIBarButtonItemStyleDone target:self action:@selector(edit:)];
}
} else{
if (self.navigationItem.rightBarButtonItem) {
self.navigationItem.rightBarButtonItem = nil;
}
}
}
navigationItem的leftBarButtonItem和rightBarButtonItem隐藏
标签:
原文地址:http://www.cnblogs.com/HMJ-29/p/5663923.html