views:

12

answers:

1

Hi!

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, @"[email protected]", 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.

+1  A: 

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

octermircty
Thank You - I have no idea how I overlooked it.
Lukasz