Iphone 当我点击tableview中的第一个单元格时,不会触发didSelectRowAtIndexPath

Iphone 当我点击tableview中的第一个单元格时,不会触发didSelectRowAtIndexPath,iphone,cell,tableview,didselectrowatindexpath,Iphone,Cell,Tableview,Didselectrowatindexpath,当我点击表格视图中的第一个单元格时,didselectrowatinexpath不会被触发。。。有没有人对此有所了解和/或有任何线索来解释为什么会发生这种情况?我表格中的所有其他单元格工作正常,我在代码中的didselectrowatinexpath中设置了一个断点,如果点击第一个单元格,应用程序不会进入该代码,但如果点击任何其他单元格,应用程序将进入该代码。 下面是一些代码: - (NSInteger)tableView:(UITableView *)tableView indenta

当我点击表格视图中的第一个单元格时,
didselectrowatinexpath
不会被触发。。。有没有人对此有所了解和/或有任何线索来解释为什么会发生这种情况?我表格中的所有其他单元格工作正常,我在代码中的
didselectrowatinexpath
中设置了一个断点,如果点击第一个单元格,应用程序不会进入该代码,但如果点击任何其他单元格,应用程序将进入该代码。 下面是一些代码:

    - (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = 0;
    return row;
}

- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    if (row == 0)
        return nil;

    return indexPath;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //NSUInteger row = [indexPath row];
    //NSString *rowValue = [poolListData objectAtIndex:row];

    int newRow = [indexPath row];
    int oldRow = [lastIndexPathForPoolList row];

    if (newRow != oldRow)
    {
        UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;

        UITableViewCell *oldCell = [tableView cellForRowAtIndexPath: lastIndexPathForPoolList]; 
        oldCell.accessoryType = UITableViewCellAccessoryNone;

        lastIndexPathForPoolList = indexPath;   
    }

    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

- (NSInteger)tableViewForDelete:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [poolListData count];
}

- (UITableViewCell *)tableViewtableViewForDelete:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *DeleteMeCellIdentifier = @"DeleteMeCellIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DeleteMeCellIdentifier];
    if (cell == nil)
    {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:DeleteMeCellIdentifier] autorelease];
    }

    NSInteger row = [indexPath row];
    cell.text = [self.poolListData objectAtIndex:row];
    return cell;
}

#pragma mark -
#pragma mark Table View Delegate Methods

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{   
    NSUInteger row = [indexPath row];
    [self.poolListData removeObjectAtIndex:row];
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}

谢谢你的时间和你能给我的任何帮助

我认为您在第一行中返回nil将选择rowforindexath。这将阻止选择该行。

很抱歉,太乱了……我似乎无法正确粘贴代码。请为您更正。lastindexpathforpoollist初始值设定项在哪里?是否设置了tableview.delegate?我在委托NSIndexPath*lastindexpathforpoollist中有lastindexpathforpoollist@属性(非原子,保留)NSIndexPath*lastIndexPathForPoolList;但是我没有初始化它(oops),初始化lastIndexPathForPoolList的最佳位置在哪里?快到了!!!我把它拿了出来,现在我可以选择第一行,但只有在我先选择任何其他行之后!!非常感谢。