在我的应用程序中,我使用 UITableview。在该委托(delegate)方法中 didselectrow 如果我做了任何操作就不会发生。
例如我在表格 View 中有 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];
}
}
请任何人帮助我。
提前致谢。
最佳答案
您已实现 didDeselectRowAtIndexPath
方法,而不是按预期实现 didSelectRowAtIndexPath
关于iphone - UITableview - TableView :didDeselectRowAtIndexPath: method not working properly?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8666356/