【问题标题】:Refresh NSTableView After Click - Not Refreshing单击后刷新 NSTableView - 不刷新
【发布时间】:2009-01-30 19:01:18
【问题描述】:

我有一个带有 UITableView 的应用程序,同时使用图标和显示按钮。我想用“已选择”图标更新一行上的图标,并用“未选择”图标更新先前选择的行。我有代码,但是当我单击行时,它将两行都设置为“选定”状态,即使通过调试我可以看到我的状态变量被设置为正确的行。如果我继续单击行,有时会显示“未选择”状态。我怀疑这是一个刷新问题,但我已经在单元格和 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];
    }

谢谢 -迈克

【问题讨论】:

    标签: iphone


    【解决方案1】:

    你试过[tableView reloadData]吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-04
      • 2020-03-06
      • 1970-01-01
      • 1970-01-01
      • 2013-04-20
      • 1970-01-01
      相关资源
      最近更新 更多