开发者

How to access the Contact image from the Address book in iphone sdk?

开发者 https://www.devze.com 2023-01-11 08:01 出处:网络
I need to get the contact image for a particular person from my add开发者_如何转开发ress book in iPhone. Can any one suggest how to access this?do this...

I need to get the contact image for a particular person from my add开发者_如何转开发ress book in iPhone. Can any one suggest how to access this?


do this...

- (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {

    // setting the first name
   // firstName.text = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);

    // setting the last name
   // lastName.text = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
        //NSMutableArray *people = [[[(NSArray*) ABAddressBookCopyArrayOfAllPeople(addressBook) autorelease] mutableCopy] autorelease];

    //[people sortUsingFunction:(int (*)(id, id, void *) ) ABPersonComparePeopleByName context:(void*)ABPersonGetSortOrdering()];

    UIImage* image;

        if(ABPersonHasImageData(person)){
            image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(person)];
            myima.image=image;
        }else{
            image = [UIImage imageNamed:@"contact_image.gif"];
            myima.image=image;
        }

    // setting the number
    /*
     this function will set the first number it finds

     if you do not set a number for a contact it will probably
     crash
     */
    //ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonPhoneProperty);
    //number.text = (NSString*)ABMultiValueCopyValueAtIndex(multi, 0);

    // remove the controller
    [self dismissModalViewControllerAnimated:YES];

    return NO;
}
0

精彩评论

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