【发布时间】:2011-12-30 19:31:21
【问题描述】:
在我的应用程序中,我使用的是 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];
}
}
请任何人帮助我。
提前致谢。
【问题讨论】:
-
显示一些实际代码可能是什么?
-
似乎在逻辑上是正确的。也许将初始化拉入 if 语句。会不会和这些部分有关?也许做
NSLog(@"%d %d", indexPath.row, indexPath.section);看看函数是否没有被调用或者你的代码是错误的。您必须清除一些选项才能更好地理解问题。
标签: iphone uitableview