Fixed Height NSTableView, Avoid Scrolling

≡放荡痞女 提交于 2019-11-29 10:45:23

In awakeFromNib you could write something like (untested):

NSScrollView *scrollView = [tableView superview];
NSView *container = [scrollView superview];
[[tableView retain] autorelease];
[tableView removeFromSuperview];
[scrollView removeFromSuperview];
[container addSubview:tableView];
[container setFrameSize:[tableView frame].size];

Alternatively, in Interface Builder you can extract a table view from a scroll view by changing to list view mode (Main Menu -> View -> as List). Then expand the view hierarchy until you see the table view. You can drag that out of the scroll view, but not into another view. You can just hook this up to an outlet and add it to a view programmatically.

You'll still need to update the height of the container when the number of rows change.

You could always extract the NSTableView from its enclosing scrollview (in code or in IB) ... You can embed the table into any container you wish, but it's up to you to maintain the table's size inside the container (and/or grow/shrink the container in response, depending n what you want to do).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!