获取NSTableView中的内容高度 [英] Get height of content in NSTableView
问题描述
有没有办法在 NSTableView
中获取内容的高度。在iOS中,您可以使用 UIScrollView
的 -contentSize
方法。然而, NSScrollView
的 -contentSize
方法似乎只返回<$ c的可见部分的高度$ c> NSScrollView ,不包括任何屏幕。
Is there a way to get the height of the content in an NSTableView
. In iOS, you can use the -contentSize
method of UIScrollView
. However, the -contentSize
method of NSScrollView
seems to just return the height of only the visible section of the NSScrollView
, not including whatever is offscreen.
那么,在Mac上怎么做呢?
So, how can this be done on a Mac?
推荐答案
- (NSSize)contentSize
在中返回
NSClipView
,而不是在表视图内滚动的内容的高度。我不知道 UIScrollView
如何工作,但在OS X上, NSScrollView
有一个内容视图更适当地命名为 NSClipView
),它剪切由文档视图提供的实际内容(如果它的大小大于剪辑视图的大小,则是可滚动的)
- (NSSize)contentSize
in Appkit
returns the size of the NSClipView
, and not the height of the content that scrolls inside the table view. I don't know how UIScrollView
s work, but on OS X, an NSScrollView
has a "content view" (more aptly named the NSClipView
) that clips the actual content, which is provided by a document view (scrollable if it has a size larger than that of the clip view) that is a subview of the clip view.
另一方面, NSScrollView
可以通过设置文档视图的边界原点据我所知)。
As a side note, the NSScrollView
scrolls by setting the document view's bounds origin (to the best of my knowledge).
它看起来像你想要的是文档视图的高度,实际内容的高度。为此,尝试类似
It looks like what you want is the height of the document view, the height of the actual content. For that, try something like
scrollView.documentView.frame.size.height
这篇关于获取NSTableView中的内容高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!