Directly open ABPersonViewController in EDIT MODE DIRECTLY in iphone

こ雲淡風輕ζ 提交于 2020-01-04 04:26:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!