问题
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