Note that there are some explanatory texts on larger screens.

plurals
  1. POSet iOS Address Book Image in UITableViewCell
    primarykey
    data
    text
    <p>I am trying to integrate the AddressBookUI API into my iOS 5 app to display selected content in a table view. I have been able to implement the AddressBook Picker and set it so when a user selects a person from their address book, it populates the label of the cell in the TableView. I would also like it to be able to display the image of the selected person in the same cell if one exists and a default missing picture image if there is not one. </p> <p>I can't see to get my head around how to store both the name and the image data in the same TableView cell. </p> <p>Anyone have any suggestions of how I might accomplish this. I have read the developer docs and know i should be using the ABPersonCopyImageDataWithFormat command. I just can't seem to get it to implement into the tableview cell.</p> <p>Here are the snippets of code I have so far:</p> <pre><code>// Store the name into memory when the user selects, then dismiss the view. - (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person { NSString *selectedPerson = (__bridge NSString *)ABRecordCopyCompositeName(person); [people insertObject:selectedPerson atIndex:0]; if (ABPersonHasImageData(person) == TRUE) { NSLog(@"Person has an image!"); } else { NSLog(@"Person does not have an image."); } [self dismissModalViewControllerAnimated:YES]; [self.tableView reloadData]; return NO; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { PartyCell *cell = (PartyCell *)[tableView dequeueReusableCellWithIdentifier:@"Cell"]; cell.backgroundView = [[GradientView alloc] init]; cell.personLabel.text = [people objectAtIndex:indexPath.row]; cell.personImage.image = [UIImage imageNamed:@"missing.png"]; // THIS NEEDS TO DISPLAY THE SELECTED USERS PICTURE. CURRENTLY SHOWS A DEFAULT USER. return cell; } </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload