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
Asked
Active
Viewed 1,782 times
3
-
did you have a look at this project- https://developer.apple.com/library/ios/#samplecode/QuickContacts/Listings/Classes_QuickContactsViewController_m.html#//apple_ref/doc/uid/DTS40009475-Classes_QuickContactsViewController_m-DontLinkElementID_6 – Jatin Apr 25 '12 at 12:58
3 Answers
2
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.

Z S
- 7,039
- 12
- 53
- 105
-
3this does not work for me. I still get person details window with Edit button at top right – Delcasda Jan 23 '14 at 16:51
1
In fact ABNewPersonViewController looks exactly like ABPersonViewController in edit mode.

Sergey Skopus
- 517
- 1
- 5
- 7
-
Great solution! And you just change the ABNewPersonViewController.Title to whatever you like, rather than "New Contact". – TreeAndLeaf Oct 23 '15 at 06:47
-2
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];

Prakash
- 605
- 6
- 16