2011-10-23 96 views
0

我在项目中使用了tableViewCell和plist文件以及数据。我想点击我所有的单元格进行活动。查看调用text.xib。代码:从表格视图单元格中推入视图

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ test *testVar = [[test alloc] initWithNibName:@"test" bundle:nil];

if ([[countries objectAtIndex:indexPath.row] isEqual:[countries objectAtIndex:indexPath.row]]){ 
    [testVar setTitle:@"Test"]; 
} 
[self.navigationController pushViewController:testVar animated:YES]; 
[testVar release]; 

}

国家 - 我的日期排列,但它是tableViewCell的主要标签。

回答

0

indexPath.sectionindexPath.row是不同的东西。让我们来想象一个数组的数组。 indexPath.section将把单个数组引用到我们的数组阵列中。 indexPath.row将引用数组中的元素,将其引入我们的数组数组中(您可以在此link上看到图)。 在你上面显示的代码,你有这种比较,进入if语句:

[[countries objectAtIndex:indexPath.section] isEqual:[countries objectAtIndex:indexPath.row]] 

你想比较同一阵列的对象,所以我相信,下面从来没有的代码执行,因为if语句总是假的。也许这可能是真的,如果你触摸表的第一行。

无论如何,检查您是否正确地为UITableView添加了委托。

相关问题