I am working on 'About" section of my iPhone application. I want to show some of the contributors details as a standard ABUnknownPersonViewController view. I am creating person view using simple 'school' code:
ABRecordRef aContact = ABPersonCreate();
ABMultiValueAddValueAndLabel(email, @"John-Appleseed@mac.com", kABOtherLabel, NULL);
ABRecordSetValue(aContact, kABPersonEmailProperty, email, &anError);
ABUnknownPersonViewController *picker =[[ABUnknownPersonViewController alloc] init];
picker.displayedPerson = aContact;
picker.alternateName = person.fullName;
picker.title = [NSString stringWithFormat:@"About %@", person.firstName];
picker.message = person.message;
... and so on ....
However - I haven't found any solution how to insert person picture to the ABUnknownPersonViewController image/picture field using <AddressBook/AddressBook.h>
.
Anybody knows if it is possible? I have no luck to find any snippet using google. There is plenty about multi-values examples, etc... but nothing about inserting image for a 'unknown' contact.
Hmm.. it worries me a bit
Thank You in advance for any hints.
This should work
UIImage *iconImage = [UIImage imageNamed:@"icon.png"];
NSData * data = UIImagePNGRepresentation(iconImage);
ABPersonSetImageData(aContact, (CFDataRef)data, nil);
Thats how I've done it in the past and it works. Basically create the image data and the set it for aContact.
Hope that helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.