2011-04-22 6 views
6

Quiero configurar el texto del encabezado para cada sección de mi UITableView agrupada.Cómo establecer el texto del encabezado de sección de la tabla de grupo

yo probamos este código, pero sale error "EXC_BAD_ACCESS"

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    if (tableView.tag==2) 
    { 
     if (section == 0) 
     { 
       return @"test1"; 
     } 
     if (section == 1) 
     { 
       return @"test2"; 
     } 
    } 
} 
+0

@Faisal: ¿de dónde sacaste EXC_BAD_ACCESS (significa qué línea)? – Jhaliya

+0

Todavía recibo un error de EXC BAD ACCESS en 'int retVal = UIApplicationMain (argc, argv, nil, nil);' –

+0

¿Está obteniendo un error en el simulador o en el dispositivo? Estoy seguro de que el problema no está en el código dado anteriormente. No está reteniendo un objeto liberado automáticamente y remitiéndolo después de su lanzamiento – Krishnabhadra

Respuesta

23

tengo trabajo, tuvo que añadir return @""; al final de prueba de fallos.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 
{ 
    if (tableView.tag==2) 
    { 
     if (section == 0) 
     { 
       return @"test1"; 
     } 
     if (section == 1) 
     { 
       return @"test2"; 
     } 
    } 
    return @""; 
} 
Cuestiones relacionadas