2010-02-27 14 views
32

? Con el siguiente código obtengo el text.label pero no el detailTextLabel.text. El NSLog se muestra correctamente.cell.detailTextLabel.text no funciona ... ¿por qué

cell.textLabel.text = [eventLabels objectAtIndex:indexPath.row]; 
cell.detailTextLabel.text = [eventFields objectAtIndex:indexPath.row]]; 

NSLog(@"%@", [eventFields objectAtIndex:indexPath.row]); 

También probé ...

cell.detailTextLabel.text = [NSString stringWithFormat:@"%@", [eventFields objectAtIndex:indexPath.row]];  

No he tenido problemas con esto antes. ¿Alguna sugerencia?

John

Respuesta

83

Asegúrese de que está utilizando una adecuada UITableViewCellStyle con esto (cosa que por lo tanto debe trabajar UITableViewCellStyleDefault). El estilo de la celda se especifica cuando lo inicializa.

+0

Eso fue todo !!!! Estaba usando pero UITableViewCellStyleDefault. Creo que usé lo que se proporcionó cuando creé la clase sin pensarlo. Muchas gracias. John – user278859

+10

usuario278859: si John ha respondido a su pregunta, entonces acepte su respuesta. ¿Cuál es el uso si no acepta incluso las respuestas correctas? –

+0

funciona como magic –

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

if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
            reuseIdentifier:CellIdentifier] autorelease]; 
} 

me acuerdo de cambiar a UITableViewCellStyleSubtitle

2

Si elige estilo UITableViewCellStyleSubtitle, su detailTextLabel.text mostrará

cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
           reuseIdentifier:CellIdentifier] ; 

UITableView Source

Cuestiones relacionadas