1

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

enter image description here

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

iosLearner
  • 1,312
  • 1
  • 16
  • 30
  • How far have you got? What *specifically* is the problem you're facing? The Xcode object library provides the Disclosure Triangle Button, so that's the hard part out of the way. Once you've got one of these on a view, all you need is a method that detects when this button is pushed, and you can then take responsibility for showing and hiding the relevant view. – Paul Patterson Dec 08 '14 at 11:21

2 Answers2

4

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

Pierre Bernard
  • 3,148
  • 2
  • 23
  • 31
2

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

Look at the Apple reference page and Outline programming topics.

Daniyar
  • 2,975
  • 2
  • 26
  • 39