单击后刷新NSTableView - 不刷新

时间:2009-01-30 19:01:19

标签: iphone

我有一个带有UITableView的应用程序,同时使用图标和公开按钮。我想使用“已选中”图标更新行上的图标,并使用“未选中”图标更新先前选择的行。我有代码,但是当我点击行时,它会将两行都设置为“selected”状态,即使通过调试我可以看到我的状态变量被设置为正确的行。如果我一直点击行,我有时会得到“未选中”状态。我怀疑它是一个刷新问题,但我已经在单元格和tableView本身上尝试了setNeedsDisplay方法,但没有运气。有没有人遇到过这个?顺便说一下,这是在模拟器(2.2.1)中 - 没有在设备上试过它。

以下是代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        int newRow = [indexPath row];
        int oldRow = [lastIndexPath row];

        if (newRow != oldRow)
        {
            [[tableView cellForRowAtIndexPath:indexPath] setImage: [UIImage imageNamed:@"IsSelected.png"]];

            c_oListPtr.c_sCurItem = [[tableView cellForRowAtIndexPath:indexPath] text];

            [[tableView cellForRowAtIndexPath:lastIndexPath] setImage: [UIImage imageNamed:@"NotSelected.png"]];

            [lastIndexPath release];
            lastIndexPath = indexPath;

            [[tableView cellForRowAtIndexPath:lastIndexPath] setNeedsDisplay];
            [[tableView cellForRowAtIndexPath:indexPath] setNeedsDisplay];
            [tableView setNeedsDisplay];
        }

        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    }

由于 -Mike

1 个答案:

答案 0 :(得分:2)

您是否尝试过[tableView reloadData]

相关问题