问题
I am developing address book app. When user selects a user from a contact list , I want to open that record directly in EDIT mode using ABPersonViewController
instead of clickng Edit button of ABPersonViewController
. How can I achieve this? Thanks
回答1:
Just call setEditing after the view is displayed:
ABPersonViewController *ab = [[ABPersonViewController alloc] init];
ab.allowsEditing = YES;
// customize as you see fit
[self.navigationController pushViewController:ab animated:YES];
[ab setEditing:YES animated:NO];
I tried this on the iPad from within a popover controller and that works fine.
回答2:
In fact ABNewPersonViewController looks exactly like ABPersonViewController in edit mode.
回答3:
I accomplished the same by doing like this:
ABRecordID personId = (ABRecordID)contact_ID;// if you want to edit a particular record and you're maintaining contact ID somewhere in your project.
ABPersonViewController *contactVC = [[ABPersonViewController alloc] init];
contactVC.personViewDelegate = self;// set your ViewController as delegate
contactVC.allowsEditing = YES; //set NO if you don't wanna allow editing
contactVC.displayedPerson = ABAddressBookGetPersonWithRecordID(addressBook, personId);
[self.navigationController presentViewController:contactVC animated:YES completion:nil];
来源:https://stackoverflow.com/questions/10315280/directly-open-abpersonviewcontroller-in-edit-mode-directly-in-iphone