Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何从iphone sdk中的通讯簿访问联系人图像?_Objective C_Ios_Cocoa Touch - Fatal编程技术网

Objective c 如何从iphone sdk中的通讯簿访问联系人图像?

Objective c 如何从iphone sdk中的通讯簿访问联系人图像?,objective-c,ios,cocoa-touch,Objective C,Ios,Cocoa Touch,我需要从iPhone中的通讯簿中获取特定人的联系人图像。有人能建议如何访问此文件吗?请执行此操作 - (BOOL)peoplePickerNavigationController: (ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person { // setting the first name // firstName.text

我需要从iPhone中的通讯簿中获取特定人的联系人图像。有人能建议如何访问此文件吗?

请执行此操作

- (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;
}
做这个

- (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;
}