无法访问iOS7中的联系人

时间:2013-10-07 09:44:56

标签: iphone ios contacts addressbook

我使用以下代码从用户手机中获取联系人

CFErrorRef  error;
__block BOOL accessGranted;
ABAddressBookRef myAddressBook = ABAddressBookCreateWithOptions(NULL,&error);
ABAddressBookRequestAccessWithCompletion(myAddressBook, ^(bool granted, CFErrorRef error) 

{
if (!accessGranted && !granted)
{
alertViewDeny = [[UIAlertView alloc]initWithTitle:@"Deny Access" message:@"Deny" delegate:self cancelButtonTitle:nil otherButtonTitles:@"cancel", nil];
[alertViewDeny show];
[alertViewDeny release];
}
else
{
NSArray *allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(myAddressBook);


   DLog(@"allPeople %@",allPeople);
}

在输出中我得到//仅适用于iOS7且它正在使用iOS6。

allPeople()

0 个答案:

没有答案