开发者

ABPersonViewController and hiding the Cancel Button

开发者 https://www.devze.com 2023-01-05 06:02 出处:网络
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 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.)

0

精彩评论

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