ABPersonViewController and hiding the Cancel Button
ABPersonViewController is by default showing a "Cancel" button in the right button bar position. How would one go about hiding/clearing that item? Obligatory code sample follows:
ABPersonViewController *picker = [[[ABPersonViewController alloc] init] autorelease];
picker.personViewDele开发者_如何学Pythongate = self;
picker.displayedPerson = aPerson;
picker.allowsEditing = NO;
Thanks.
SOLVED! Subclass ABPersonViewController
, override -(void) viewDidLoad
, call the super and THEN set the rightBarButtonItem
to nil
. Ta da!
@interface PersonViewController : ABPersonViewController
@end
@implementation PersonViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.rightBarButtonItem = nil;
}
@end
Much simpler:
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];
(Simply added rightBarButtonItem = nil after pushViewController.)
精彩评论