tags:

views:

177

answers:

1

Using the code below, how do I put an image in each section for this table view.

     switch (indexPath.section) {
        case TYPE_SECTION: // type -- should be selectable -> checkbox
            text = [patient.type valueForKey:@"name"];
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;
            break;
        case NOTES_SECTION:
            text = @"Notes Entry";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.editingAccessoryType = UITableViewCellAccessoryNone;
            break;
    case SCHEDULES_SECTION:
            text = @"Appointments Entry";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.editingAccessoryType = UITableViewCellAccessoryNone;
            break;
    case LAB_SECTION:
            text = @"Labs Entry";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.editingAccessoryType = UITableViewCellAccessoryNone;
            break;
    case STATUS_SECTION:
            text = @"Status Entry";
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
            cell.editingAccessoryType = UITableViewCellAccessoryNone;
            break;
        default:
            break;
    }

    cell.textLabel.text = text;
}
return cell;

}

A: 
// snip
case STATUS_SECTION:
  text = @"Status Entry"; 
  cell.accessoryType = UITableViewAccessoryTypeDisclosureIndicator;
  cell.editingAccessoryType = UITableViewCellAccessoryNone;
  [cell.imageView setImage:[UIImage imageNamed:@"any-image-in-my-project.png"]];
  break;
// snip
pix0r
Thanks. I originally had...cell.image = [UIImage imageNamed:@"walk.png"];However I kept getting warnings saying: 'setImage:' is deprecated (declared at /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/System/Library/Frameworks/UIKit.framework/Headers/UITableViewCell.h:200)...Do you know what this warning is about? Strange to me, but it works... However, your code does not give me that warning..
SympleMyne
It used to be the case you set images on cells directly, now you are supposed to set the image in an UIImageView that you get out of the cell. That's why you get a warning with .image, it works now but in a few releases of iPhone OS will stop working.
Kendall Helmstetter Gelner
Is that the reason i get the same warning for this peace of code:NSDictionary *dictionary = [self.tableDataSource objectAtIndex:indexPath.row]; cell.text = [dictionary objectForKey:@"Title"]; return cell;}
SympleMyne