我在CNContact中设置了imageData并保存,但当我打电话给我保存的人时,headImage无法正常工作。
keyPressed(noteData) {
console.log(noteData); // {key: 30, keyType: "white"}
this.pressed = noteData;
noteCanvas.drawImage();
}
答案 0 :(得分:0)
如果您需要图像数据,则需要创建一个获取请求。
CNContactStore *contactStore = [[CNContactStore alloc] init];
NSPredicate *predicate = [CNContact predicateForContactsWithIdentifiers:@[[contact identifier]]];
CNContactFetchRequest *request = [[CNContactFetchRequest alloc] initWithKeysToFetch:@[[CNContactVCardSerialization descriptorForRequiredKeys],
CNContactImageDataKey,
CNContactThumbnailImageDataKey
]];
[request setPredicate:predicate];
NSError *error;
NSMutableArray *mutArray = [NSMutableArray array];
[contactStore enumerateContactsWithFetchRequest:request error:&error usingBlock:^(CNContact * _Nonnull fetchedContact, BOOL * _Nonnull stop) {
[mutArray addObject:fetchedContact];
}];
}