how to check whether organization name is added before saving contact in address book?

百般思念 提交于 2019-12-04 17:09:45

There is no documented way to do this using ABNewPersonViewController, because when the delegate method is called, the person is already saved by the ABNewPersonViewController. Formerly you should made your own "insert controller" and use it.

But I tried this workaround and obtained this behavior (on iOS 6):

in the delegate method

- (void)newPersonViewController:(ABNewPersonViewController *)newPersonView didCompleteWithNewPerson:(ABRecordRef)person

you receive a ref to the new person created. You can then access to the person saved and check if the company has been compiled. If not, simply you don't call

[self dismissModalViewControllerAnimated:YES];

The ABNewPersonViewController will stay in position, and you can show an alert to the user asking him to compile the company. The fields will remain compiled and ABNewPersonViewController "linked" to the new user created.

Then, the user can:

  • compile the company field --> a tap on Save will update the saved person and give your delegate new data, so you can dismiss the viewcontroller correctly
  • tap cancel --> you receive the cancel, and the person is deleted by the ABNewPersonViewController itself

But...because I can't find this behavior documented in any place, I'm not sure if

  • it will work on other versions
  • it will "survive" to the review process (formerly you are not using private API, but not sure if "not closing" the viewcontroller when the user taps save is not good for the UI Guidelines)

Regards Fabio

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