0
J'essaie d'appliquer une coche dans une application en mode tableau. il fonctionne dans Simulator 2.2.1 mais pas dans le simulateur 3.0.cell.accessoryType dans Simulator 3.0?
J'essaie d'appliquer une coche dans une application en mode tableau. il fonctionne dans Simulator 2.2.1 mais pas dans le simulateur 3.0.cell.accessoryType dans Simulator 3.0?
Le code suivant vous permet d'ajouter une coche sur une cellule UITableView.
Testé avec succès avec le simulateur iPhone sous SDK 2.2.1 et 3.0.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Create or reuse cell
NSString *CellIdentifier = [NSString stringWithFormat:@"%d:%d", [indexPath indexAtPosition:0], [indexPath indexAtPosition:1]];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
// Modify cell
switch ([indexPath indexAtPosition:0]) {
case(0): // First section
switch ([indexPath indexAtPosition:1]) {
case(0): // First cell
cell.textLabel.text = @"Text";
cell.accessoryType = UITableViewCellAccessoryCheckmark;
break;
}
}
return cell;
}
Un tas de choses dans UITableViewCell était obsolète dans 3.0, mais accessoryType ne l'était pas, et devrait toujours fonctionner correctement. Pouvez-vous poster le code? – zpasternack