Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Image to Table Cell (iOS)

I am trying to do something similar to twitter or Facebook.

like image 922
145478272452 Avatar asked Mar 06 '11 17:03

145478272452


2 Answers

- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath 
{    
   static NSString* CellIdentifier = @"Cell";

   UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   if (cell == nil)
      cell = [[[UITableViewCell alloc] UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

   cell.textLabel.text = @"I'm a UITableViewCell!";
   cell.imageView.image = [UIImage imageNamed:@"MyReallyCoolImage.png"];

   return cell;
}

Credit to Thomas Moore

adding images to UItableView

like image 153
Erick Smith Avatar answered Oct 31 '22 13:10

Erick Smith


Well, to add an image to a table cell, you would add a UIImage to the image property of a subtitle UITableViewCell or your own custom Cell. I would read the doc on Customizing UITableViewCells at developer.apple.com.

like image 28
W Dyson Avatar answered Oct 31 '22 15:10

W Dyson