向NSScrollView添加大量视图 [英] Add lots of views to NSScrollView

查看:219
本文介绍了向NSScrollView添加大量视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图为字典中的每个元素添加一个子视图( NSViewController 视图)到 NSScrollView

I'm trying to add one subview (view from an NSViewController) for every element in a dictionary to a NSScrollView to get kind of a tableview, but with much more flexibility over the cells.

可以放置(以编程方式)例如100个子视图,以便您必须向下滚动 NSScrollView 才能到达最后一个元素

Is it possible to place (programmatically) e.g. 100 subviews underneath each other so that you have to scroll down the NSScrollView to get to the last element???

感谢高级,
Grolior

Thanks in advanced, Grolior

推荐答案

简短的答案是肯定的。我以前做过,我向你保证,它会工作。让我也向你保证,它不是那么简单,它看起来;)

The short answer is yes. I have done this before, and I assure you that it will work. Let me also assure you that it is not quite as simple as it looks ;)

是维护一个内容视图,其中您以编程方式添加所有自定义行作为子视图。请注意,您必须在添加所有行之前重新调整contentView 的大小,否则您必须关闭行视图的自动调整大小。将您的 scrollView documentView 添加到此自定义contentView,您应该很好。

The way to do this is to maintain one content view, in which you add all of your custom rows as subviews programmatically. Note that you will either have to resize the contentView before adding all of the rows, or you will have to turn off autoresizing for the row views. Set the documentView of your scrollView to this custom contentView, and you should be good to go.

这篇关于向NSScrollView添加大量视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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