默认情况下,ABPersonViewController在右侧按钮栏位置显示“取消”按钮。如何隐藏/清除该项目?强制性代码示例如下:
ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
picker.personViewDelegate = self;
picker.displayedPerson = aPerson;
picker.allowsEditing = NO;
感谢。
答案 0 :(得分:4)
解决了!子类ABPersonViewController
,覆盖-(void) viewDidLoad
,调用超级,然后将rightBarButtonItem
设置为nil
。塔达!
@interface PersonViewController : ABPersonViewController
@end
@implementation PersonViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = nil;
}
@end
答案 1 :(得分:1)
更简单:
ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
picker.personViewDelegate = self;
picker.displayedPerson = aPerson;
picker.allowsEditing = NO;
[self.navigationController pushViewController:picker animated:YES];
picker.navigationItem.rightBarButtonItem = nil; // remove "Cancel" button
[picker release];
(在pushViewController之后简单地添加了rightBarButtonItem = nil。)