When I display an ABPersonViewController
, I need a button that allows me to dismiss it and return to the previous screen. How do I add this?
Asked
Active
Viewed 2,544 times
1

bfavaretto
- 71,580
- 16
- 111
- 150

pcjbird
- 109
- 1
- 8
2 Answers
5
Oh, I got the answer.
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)];

pcjbird
- 109
- 1
- 8
-
After clicking the edit button, and back, the backBarButton will be disappeared. – Steven Jiang Apr 19 '13 at 01:06
0
As variant:
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:)];

jamapag
- 9,290
- 4
- 34
- 28
-
Thanks. However, if the ABPersonViewController is the init view of navigation controller, that is to say, there is no more views at navigationcontroller's stack, and then how to return the before view, which is not contains a navigation bar. – pcjbird Aug 06 '10 at 00:26