将图像添加到表格单元格(iOS)

145*_*452 9 iphone image objective-c uitableview ios

我正在尝试做类似于Twitter或Facebook的事情.

Eri*_*ith 18

- (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;
}
Run Code Online (Sandbox Code Playgroud)

感谢Thomas Moore

将图像添加到UItableView


W D*_*son 1

那么,要将图像添加到表格单元格,您可以将 UIImage 添加到子标题 UITableViewCell 或您自己的自定义单元格的图像属性中。我会在developer.apple.com 上阅读有关自定义UITableViewCells 的文档。