views:

34

answers:

1

How to set different icon image for each cell in the UItable View.

A: 

In your tableview delegate:

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