开发者

Clean easy way to expand window according to subviews

I'm developing an application that uses a master-d开发者_开发知识库etail paradigm with an NSTableView as the master and an NSView as the detail. The NSView gets populated from another NSViewController's view; I have an individual NSViewController for each of the detail views and their views are configured in XIBs. What's the cleanest way to have the main window expand only as necessary (preferably with animation) to fit the current detail view (similar to what System Preferences does)? Sorry if this is an elementary question; I'm rather new at desktop Cocoa.


Calculate the size of the window you need to accommodate your master and selected detail view. You can get the size of your detail view:

NSSize detailViewFrameSize = [[detailViewController view] frame].size;

Resize the window:

[window setFrame:frameRect display:YES animate:YES];

Add the detail subview to the specified position.

[[window contentView] addSubview:detailView];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜