如何为A Person View Controller的导航栏添加一个返回按钮?

时间:2010-08-05 12:16:46

标签: iphone ios uinavigationcontroller abpersonviewcontroller

当我显示ABPersonViewController时,我需要一个按钮,允许我将其关闭并返回上一个屏幕。我该如何添加?

2 个答案:

答案 0 :(得分:5)

哦,我得到了答案。

ABPersonViewController *personViewController = [[ABPersonViewController alloc] init];
personViewController.addressBook = addr;
personViewController.displayedPerson = ABAddressBookGetPersonWithRecordID(addr, (ABRecordID)personID);
personViewController.allowsEditing = YES;
personViewController.personViewDelegate = self;     
personViewController.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Return",nil) style:UIBarButtonItemStylePlain target:self action:@selector(ReturnFromPersonView)];

答案 1 :(得分:0)

作为变体:

ABPersonViewController *personView = [[ABPersonViewController alloc] init];
[self.navigationController pushViewController:personView animated:YES];
personView.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"return" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];