NSTableView的viewForTableColumn:row:在小牛中调用比预期更多的行 [英] NSTableView's viewForTableColumn:row: called for more rows than expected in Mavericks

查看:897
本文介绍了NSTableView的viewForTableColumn:row:在小牛中调用比预期更多的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我使用以下命令确认了这一点:$ b​​ $ b NSRange rowsInRect = [aTableView rowsInRect:[aTableView visibleRect]];
NSInteger lastVisibleRow = rowsInRect.location + rowsInRect.length;



但是对于小牛,viewForTableColumn:row被调用了更多次而不向下滚动。



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



任何人都可以解释这个问题吗?

解决方案

这在AppKit OS X v10.9的发行说明。



这里:


Mac OS 10.9有一个新功能叫响应滚动。响应式滚动允许应用程序继续快速滚动内容,即使应用程序的主线程正忙于进行其他工作。 AppKit通过使文档视图绘制比当前在空闲期间可见的更多来实现这一点。



为了便于响应式滚动,您的文档视图将被要求绘制用户当前不可见的部分。



以下方法由NSView使用rect调用推荐区域,该区域应该完全呈现为过度绘制。覆盖此方法,并为rect带来额外的子视图和预先缓存的内容,以便执行响应式滚动。
要禁止特定视图(例如NSTableView)的重绘,请覆盖此方法并调用[super prepareContentInRect:[self visibleRect]]。



< prepareContentInRect:(NSRect)rect;



My understanding was that viewForTableColumn:row: would be called only for rows that are visible.

I confirmed this using the following: NSRange rowsInRect = [aTableView rowsInRect:[aTableView visibleRect]]; NSInteger lastVisibleRow = rowsInRect.location + rowsInRect.length;

But with Mavericks, viewForTableColumn:row is getting called many more times without scrolling down.

For example, if my last visible row was 35, data source method is called for 139 rows.

Can anybody explain this?

解决方案

I found the explanation to this in AppKit Release notes for OS X v10.9.

Here goes:

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;

这篇关于NSTableView的viewForTableColumn:row:在小牛中调用比预期更多的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆