gpt4 book ai didi

objective-c - ABAddressBookRequestAccessWithCompletion 在 iOS 10 上崩溃

转载 作者:太空狗 更新时间:2023-10-30 03:46:28 24 4
gpt4 key购买 nike

我使用以下代码访问我的 iOS 应用程序中的联系人。它在 iOS<10 中运行良好,但在 Xcode 8 和 iOS 10 中它崩溃了:

- (void)btcContacts_tap {
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, NULL);
ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) {
if (granted) {
_addressBookController = [[ABPeoplePickerNavigationController alloc] init];

[[_addressBookController navigationBar] setBarStyle:UIBarStyleBlack];

_addressBookController.delegate = self;
[_addressBookController setPredicateForEnablingPerson:[NSPredicate predicateWithFormat:@"%K.@count > 0", ABPersonPhoneNumbersProperty]];
[_addressBookController setPeoplePickerDelegate:self];
[self presentViewController:_addressBookController animated:YES completion:nil];
}
else {
dispatch_async(dispatch_get_main_queue(), ^{
[self showMessage:NSLocalizedStringFromTable(@"PLEASE_GRANT_CONTACTS", LIApplicationLanguage(), nil) andAdvertise:@"" andService:nil andTransactionState:kTTTransactionStateInfo];
});
}
});
}

我已经将 NSSetUncaughtExceptionHandler 设置为记录崩溃报告的方法,但即使是异常处理程序也没有调用...

其他人也遇到过这个问题吗?

最佳答案

iOS 10:

您需要将 NSContactsUsageDescription 放入您的 plist 中。喜欢:

<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) uses photos</string>

查看所有使用说明 here .

关于objective-c - ABAddressBookRequestAccessWithCompletion 在 iOS 10 上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38282883/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com