Objective c UITableView未正确选择

Objective c UITableView未正确选择,objective-c,uitableview,Objective C,Uitableview,我正在开发一个iPhone应用程序,其中我有一个UITableView,它通过URL填充了一个XML提要 比如说,有三个单元格被填充 如果我点击第一个单元格,什么都不会发生,但是如果我点击第二个或第三个单元格,它会将我带到与第一个单元格相关的第二个屏幕,其他单元格也会发生同样的情况-点击它,什么都不会,点击另一个,它会将我带到上一个选定单元格的第二个屏幕 我以前从未遇到过这种情况,我相当困惑 - (UITableViewCell *)tableView:(UITableView *)tableV

我正在开发一个iPhone应用程序,其中我有一个UITableView,它通过URL填充了一个XML提要

比如说,有三个单元格被填充

如果我点击第一个单元格,什么都不会发生,但是如果我点击第二个或第三个单元格,它会将我带到与第一个单元格相关的第二个屏幕,其他单元格也会发生同样的情况-点击它,什么都不会,点击另一个,它会将我带到上一个选定单元格的第二个屏幕

我以前从未遇到过这种情况,我相当困惑

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];

    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 
                              reuseIdentifier:@"UITableViewCell"];
    }

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    LocationsItem *atm = [[locations atms] objectAtIndex:[indexPath row]];
    [[cell textLabel] setText:[atm atmName]];

    float distance = [[atm atmDistance] floatValue];
    NSString *distanceString = [NSString stringWithFormat:@"%0.2f miles from current location", distance];
    [[cell detailTextLabel] setText:distanceString];

    return cell;
}

- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    LocationsItem *atm = [[locations atms] objectAtIndex:[indexPath row]];

    ATMDetailsController *detailsController = [[ATMDetailsController alloc] init];

    [detailsController setCurrentATM: atm];

    [[self navigationController] pushViewController:detailsController animated:YES];

}
谢谢,
尼克,你回答了你自己的问题。问题是您使用了
tableView:deselectRowAtIndexPath:
而不是
tableView:didSelectRowAtIndexPath:

值得注意的是,这是因为字典中
deselect
出现在
did
之前,这是一个不幸的事实,因此,xcode通常非常棒的代码完成让您感到惊讶


现在去把那些小时的调试工作拿回来

请发布您的CellForRowatineXpath:code听起来像是您在
tableView:DidSelectRowatineXpath:
中的索引被关闭了一次,但是如果没有看到相关的代码,就无法确定。感谢您的查看,我已经在上面粘贴了一些代码。请尝试放置
NSLog(@“%@调用行:%d,使用atm:%@),NSStringFromSelector(\u cmd),indexath.row,atm.atmName)在您发布的两个方法的末尾附近。您使用的是哪个版本的Xcode&iOS?我刚刚注意到我的问题-我使用的是“DidSelectRowatineXpath”,而不是“DidSelectRowatineXpath”。我真傻,我也有同样的问题。浪费了一个小时想弄清楚到底发生了什么。需要更加注意自动完成和语法,lol。