1

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?

bfavaretto
  • 71,580
  • 16
  • 111
  • 150
pcjbird
  • 109
  • 1
  • 8

2 Answers2

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
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