获取NSTableView中的内容高度 [英] Get height of content in NSTableView

查看:225
本文介绍了获取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 UIScrollViews 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屋!

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