开发者

Insert picture image to the ABUnknownPersonViewController view in iPhone application contact page

开发者 https://www.devze.com 2023-01-15 08:45 出处:网络
I am working on \'About\" section of my iPhone application. I want to show some of the contributors details as a standard AB开发者_开发知识库UnknownPersonViewController view.

I am working on 'About" section of my iPhone application. I want to show some of the contributors details as a standard AB开发者_开发知识库UnknownPersonViewController 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

0

精彩评论

暂无评论...
验证码 换一张
取 消