从表格视图单元格中推送视图

时间:2011-10-23 20:40:36

标签: objective-c cocoa-touch

我在我的项目中使用了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];

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

countries - 我的日期数组,但它是tableViewCell的主要标签。

1 个答案:

答案 0 :(得分:0)

indexPath.sectionindexPath.row是不同的事情。让我们想象一个数组数组。 indexPath.section将单个数组引用到我们的数组数组中。 indexPath.row会将一个元素引用到数组中,并引用到我们的数组数组中(您可以在此link上看到一个图表)。 在上面显示的代码中,您将此比较转换为if语句:

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

您正在尝试比较同一个数组的对象,因此我假设下面的代码永远不会执行,因为if语句始终为false。如果你触摸表格的第一行,也许可能是真的。

无论如何,检查你是否正确添加了UITableView的委托。

相关问题