iOS开发 调用系统联系人

// 首先要导入下面两个库
AddressBook.framework
AddressBookUI.framework

// 导入头文件
#import <AddressBook/AddressBook.h> 
#import <AddressBookUI/AddressBookUI.h> 


目标很简单,就是按Click之后,调用系统联系人,然后按“取消”按钮返回。

下面这段代码在iOS8之前是好用的。到iOS9就会有问题,就是联系人画面被调出来之后,右上角的[取消]按钮没了,导致程序退不回去。
但是把①和②替换,就可以正常使用了。原因还不知道。




// 这是Click按钮按下时的事件处理
- (IBAction)setOutput:(id)sender {
    userOutput.text = userInput.text;
    NSLog(@"Press the button");
 
    ABPeoplePickerNavigationController* llViewController = [[ABPeoplePickerNavigationController alloc] init];
    [self.view addSubview:llViewController.view];   // ①
//    [self presentViewController:llViewController animated:YES completion:nil];  // ②
}
 
- (void)peoplePickerNavigationControllerDidCancel:(ABPeoplePickerNavigationController *)peoplePicker
{
    //[peoplePicker dismissViewControllerAnimated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
 
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值