我尝试使用unifiedContactWithIdentifier:keysToFetch:error:并使用CNContact
ImageDataKey重新获取CNContact后获取imageData,
在目标C.
在目标C.
在运行期间,我总是有相同的异常CNPropertyNotFetchedException甚至重新联系并检查imageData调用imageDataAvailable.这没有意义.
swift中的相同代码很棒.
那么,目标C的Contact框架中是否存在问题?
我在iOS 6和iPhone 9.0.2上使用XCode 7.0构建.
这里的代码:
// ...
// ...
if([currentNativeContact isKeyAvailable:CNContactimageDataKey] &&
currentNativeContact.imageDataAvailable) {
previewImage = [UIImage imageWithData:currentNativeContact.thumbnailImageData];
}
else {
NSError *error;
currentNativeContact = [self.contactsstore unifiedContactWithIdentifier:currentNativeContact.identifier keysToFetch:@[CNContactimageDataKey] error:&error];
if(!error && currentNativeContact.imageDataAvailable)
previewImage = [UIImage imageWithData:currentNativeContact.thumbnailImageData];
}
谁能帮我 ?
谢谢,
米歇尔
解决方法
您需要将CNContactimageDataAvailableKey和CNContactThumbnailImageDataKey添加到keysToFetch.