Get a Contact Picture ios

只愿长相守 提交于 2019-12-06 14:26:40
Bhavin

To get the FirstName and LastName , you can use :

NSString *firstName = (NSString *)ABRecordCopyValue(aABRecordRef, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue(aABRecordRef, kABPersonLastNameProperty);

Here it shows how to Search By Number and Get the image using ABAddressBook.

But you want to search By FirstName and LastName. So According to the Documentation , you should use -recordsMatchingSearchElement: method for Multiple Arguments.

Once you get the matched Data , you can extract the image using below code :

CFDataRef imageData = ABPersonCopyImageData(aABRecordRef);
UIImage *image = [UIImage imageWithData:(NSData *)imageData];
CFRelease(imageData);

Hope you get something useful from this.

Try:

CFStringRef firstName, lastName; // can cast this to NSString *

firstName = ABRecordCopyValue(aABRecordRef, kABPersonFirstNameProperty);
lastName = ABRecordCopyValue(aABRecordRef, kABPersonLastNameProperty);  
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!