tags:

views:

73

answers:

2

How to add a return button for ABPersonViewController's navigationbar?

A: 

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

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