Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在iOS sdk中的现有组上添加联系人_Ios_Objective C_Iphone_Abaddressbook_Abaddressbooksource - Fatal编程技术网

如何在iOS sdk中的现有组上添加联系人

如何在iOS sdk中的现有组上添加联系人,ios,objective-c,iphone,abaddressbook,abaddressbooksource,Ios,Objective C,Iphone,Abaddressbook,Abaddressbooksource,我正在开发联系人应用程序,我想在其中添加3个不同组(即A、B、C)的联系人。以及使用本机联系人创建添加(创建)新联系人 ABRecordRef person = ABPersonCreate(); ABUnknownPersonViewController *controller = [[ABUnknownPersonViewController alloc] init]; controller.displayedPerson = person; controller.allowsAddingT

我正在开发联系人应用程序,我想在其中添加3个不同组(即A、B、C)的联系人。以及使用本机联系人创建添加(创建)新联系人

ABRecordRef person = ABPersonCreate();
ABUnknownPersonViewController *controller = [[ABUnknownPersonViewController alloc] init];
controller.displayedPerson = person;
controller.allowsAddingToAddressBook = YES;

[self.navigationController pushViewController:controller animated:YES];
这将在联系人簿上添加联系人。但我想加上A、B和C组

如何使用本机添加联系人屏幕将此联系人添加到组中

请帮帮我

我希望它能起作用

您可以通过使用
ABNewPersonViewController
来实现这一点,该控制器位于地址簿框架中:

低于iOS 9:

ABNewPersonViewController *addContactVC = [[ABNewPersonViewController alloc] init];
addContactVC.newPersonViewDelegate      = self;
UINavigationController *navController   = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentModalViewController:navController animated:YES];
iOS 9或更高版本:

ABNewPersonViewController *addContactVC = [[ABNewPersonViewController alloc] init];
addContactVC.newPersonViewDelegate      = self;
UINavigationController *navController   = [[UINavigationController alloc] initWithRootViewController:addContactVC];
[self presentModalViewController:navController animated:YES];
您可以使用ContactsUI框架的CNContactViewController:

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