如何设置不同。图像在表格中的单元格

时间:2009-12-05 08:53:14

标签: iphone objective-c

如何在UItable视图中为每个单元格设置不同的图标图像。

1 个答案:

答案 0 :(得分:0)

在tableview委托中:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.imageView.image=[someDataClass methodThatReturnsAnImage]; 
    cell.textLabel.text=[someDataClass methodThatReturnsAString]; 
    return cell;
}