【问题标题】:How to get the row in a NSTableView when rowAtPoint: doesn't reflect the partially visible top row?当 rowAtPoint: 不反映部分可见的顶行时,如何获取 NSTableView 中的行?
【发布时间】:2014-04-16 08:35:38
【问题描述】:

这是 NSTableView 中顶部可见行完全可见的结果:

======
        rowAtPoint: -> 0
        rowAtPoint: -> 0
------  
        rowAtPoint: -> 1
        rowAtPoint: -> 1
------

但是当 NSTableView 处于顶部可见行仅部分可见的滚动位置时,我会得到这种结果:

======
        rowAtPoint: -> 0
------  
        rowAtPoint: -> 0   should be 1
        rowAtPoint: -> 1
------  
        rowAtPoint: -> 1   should be 2
        rowAtPoint: -> 2
------

我是否误解了 rowAtPoint: 的目的?

【问题讨论】:

    标签: cocoa nstableview


    【解决方案1】:

    -[NSTableView rowAtPoint:] 在表格的坐标系中工作。我猜您使用的是相对于封闭 NSClipView 的点。使用-[NSView convertPoint:fromView:] 或类似的方法来获得正确的坐标。

    【讨论】:

      猜你喜欢
      • 2017-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-05
      • 2012-11-10
      相关资源
      最近更新 更多