UITableview - tableView:didDeselectRowAtIndexPath:方法无法正常工作?

KAR*_*MED 5 iphone uitableview

在我的应用程序中,我正在使用UITableview.在那个委托方法中,如果我做了任何操作,那么就不会发生.

例如,我在tableview中有3行

如果我选择1行(indexPath.row == 0)则不会发生任何事情

如果再次选择2行(indexPath.row == 1),现在它是登录控制台indexPath.row == 0这是以前的值.

如果再次选择1行,则记录其前一个值indexPath.row = 1.

为什么会这样.

- (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];
    }
}
Run Code Online (Sandbox Code Playgroud)

请有人帮帮我.

提前致谢.

Vla*_*mir 19

你已经实现了didDeselectRowAtIndexPath方法,而不是didSelectRowAtIndexPath预期的方法

  • omfg我花了太长时间用这个作为我的问题!大声笑 (3认同)