gpt4 book ai didi

cocoa - NSTableView的viewForTableColumn :row: called for more rows than expected in Mavericks

转载 作者:行者123 更新时间:2023-12-03 16:13:09 25 4
gpt4 key购买 nike

我的理解是 viewForTableColumn:row: 只会针对可见的行调用。

我使用以下内容确认了这一点:NSRange rowsInRect = [aTableView rowsInRect:[aTableViewvisibleRect]];NSInteger lastVisibleRow = rowsInRect.location + rowsInRect.length;

但是对于 Mavericks,viewForTableColumn:row 会在不向下滚动的情况下被调用很多次。

例如,如果我的最后一个可见行是 35,则为 139 行调用数据源方法。

谁能解释一下吗?

最佳答案

我在 OS X v10.9 的 AppKit 发行说明中找到了对此的解释。

这里是:

Mac OS 10.9 has a new feature called Responsive Scrolling. Responsive Scrolling allows the application to continue to rapidly scroll content even when the application’s main thread is busy doing other work. AppKit accomplishes this by having the document view draw more than what is currently visible during idle.

To facilitate Responsive Scrolling, your document view will be asked to draw portions that are not currently visible to the user.

The following method is called by NSView with a 'rect' for a recommended area that should be fully rendered for overdraw. Override this method and bring in additional subviews and pre-cached content for the 'rect' in order to perform responsive scrolling. To suppress overdraw for a particular view (such as NSTableView), override this method and call [super prepareContentInRect:[self visibleRect]].

(void)prepareContentInRect:(NSRect)rect;

关于cocoa - NSTableView的viewForTableColumn :row: called for more rows than expected in Mavericks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23013990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com