Can I get and use the contact picture in my app?
I'm using the address book framework to get all the contacts from my iphone phonebook.
Is ther开发者_高级运维e any way to get (and use) the contact picture?
Thank you.
Thomas
Yes you can. You need to check out the Address Book documentation for iOS and especially look at the ABPerson reference.
http://developer.apple.com/library/ios/documentation/AddressBook/Reference/ABPersonRef_iPhoneOS/Reference/reference.html#//apple_ref/doc/uid/TP40007210
Yes you can... this code from the Address Book API
array = [peoplePicker selectedRecords];
NSAssert([array count] == 1, @"Picker returned multiple selected records");
ABPerson *person = [array objectAtIndex:0];
personImage = [[NSImage alloc] initWithData:[person imageData]];
personFirstName = [person valueForProperty:kABFirstNameProperty], personLastName = [person valueForProperty:kABLastNameProperty];
/* ...do something with the image and name... */ [personImage release];
Here is a nice article how to pull pictures depending on the iOS version (pre 4.1 and currently preferred method)
精彩评论