How to do collapse and expand view in mac application?

橙三吉。 提交于 2019-12-08 07:21:05

问题


I am new to mac application development, here i want to do expand and collapse view in my custom view(NSView)

here the sample image

How can i achieve these kind of collapse and expand cell in NSViewController not in NSWindow...

Is it possible using NSTableView?

I know its a simple question but i facing problem.

Please suggest me some sample code or links..

Thanks


回答1:


Collapsing / expanding can be implemented by adjusting auto layout constraints in the action method of the disclosure triangle button.

@property (nonatomic, weak) IBOutlet NSLayoutConstraint *moreInfoBoxHeight;

[[self.moreInfoBoxHeight animator] setConstant:75];

Apple has sample code using NSStackView at https://developer.apple.com/library/mac/samplecode/InfoBarStackView/Introduction/Intro.html




回答2:


The view at the picture given is NSOutlineView. It is the NSTableView subclass.

Look at the Apple reference page and Outline programming topics.



来源:https://stackoverflow.com/questions/27352431/how-to-do-collapse-and-expand-view-in-mac-application

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