En mi aplicación estoy usando UITableview. En ese método delegado didselectrow si hice cualquier operación no puede suceder solo.UITableview - tableView: didDeselectRowAtIndexPath: ¿el método no funciona correctamente?
Por ejemplo tengo a 3 filas en tableview
si selecciono 1 fila (indexPath.row == 0) no pasará nada
si seleccione de nuevo 2 fila (indexPath.row == 1) ahora está Iniciando sesión en la consola indexPath.row == 0, que es el valor anterior.
si de nuevo selecciona 1 fila y luego registra su valor anterior indexPath.row = 1.
¿Por qué esto va como.
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomerInfoViewController *customer = [[EquipmentViewController alloc]initWithNibName:@"CustomerInfoViewController" bundle:nil];
EquipmentViewController *equpment = [[EquipmentViewController alloc]initWithNibName:@"EquipmentViewController" bundle:nil];
ContactsViewController *contacts = [[ContactsViewController alloc]initWithNibName:@"ContactsViewController" bundle:nil];
if(indexPath.row == 0)
{
NSLog(@"one %d",indexPath.row);
[detailsView addSubview:customer.view];
}
if(indexPath.row == 1)
{
NSLog(@"two %d",indexPath.row);
[detailsView addSubview:equpment.view];
}
if(indexPath.row == 2)
{
NSLog(@"three%d",indexPath.row);
[detailsView addSubview:contacts.view];
}
}
Por favor, que alguien me ayude.
Gracias de antemano.
¿Mostrar un código real? – Vladimir
Parece ser lógicamente correcto. Tal vez saque las inicializaciones en las declaraciones if. ¿Podría tener algo que ver con las secciones? Tal vez haga 'NSLog (@"% d% d ", indexPath.row, indexPath.section);' para ver si la función no se llama o si su código es simplemente incorrecto. Debe aclarar algunas opciones para comprender mejor el problema. – DAS