How to add a Contact in Contact using iPhone Native UI

爱⌒轻易说出口 提交于 2019-12-10 12:04:12

问题


I Want to add phone numbers in Contact List whenever user taps on a Phone Number.

I don't want to do it programatically in background and after saving just inform user.

I have recently seen Feature in trueCaller. In which When I click save to contact button then iPhone's default Contact add Screen is opened with Clicked Phone Number. I Searched SO and Web but found only adding via code.

How can I achieve this please assist me.


回答1:


Below iOS 9:

You can achieve that by using ABNewPersonViewController available in the Addressbook Framework:

ABNewPersonViewController *addContactVC = [[ABNewPersonViewController alloc] init];
addContactVC.newPersonViewDelegate      = self;
UINavigationController *navController   = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentModalViewController:navController animated:YES];

iOS 9 or greater:

You can use CNContactViewController of ContactsUI Framework

CNContactViewController *addContactVC = [CNContactViewController viewControllerForNewContact:contact];
addContactVC.delegate                 = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentViewController:navController animated:NO completion:nil];


来源:https://stackoverflow.com/questions/33886834/how-to-add-a-contact-in-contact-using-iphone-native-ui

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