0
votes

I have a following problem:

I have NSScrollView in which I would like to add subviews from the bottom one below another. I started using addSubview but I don't how to position it in a proper way in that NSScrollView. NSScrollView has a fixed size and when it will be filled it should allow user to scroll. Adding subviews to the scroll view adds it to the top of scrollView. Adding more then one subview put them one on another. I tried also with adding constraints from code but adding I'm not sure if it's good attitude because adding new subview would force me to change constraints of every previouse added subview. I would be thankful for any hint or direction.

Edit: Actually I moved from another appropach to this problem. I had created NSTableView in which I was adding views but the problem I encountered was the fact of adding views to the bottom of the table. So additional question is if it was good idea to swich to the pure NSScrollView.

1
Are you adding your views to the NSScrollView's documentView? The documentView is the one that is scrolled.Stefanf
I have NSScrollView in which I have NSView' and in it View'. I have IBOutlet for NSScrollView and I'm using method addSubiew on this.PawelPawel
then try adding it to scrollView.documentView and make sure the frame of the documentView is adjusted to wrap around all it's subviews.Stefanf
Done. DocumentView wrap all content. Document View is ClipView in the scrollView, right? Adding to the contentView helped a little bit because it adds views from the bottom but still one on the another.PawelPawel
Are you setting the the frame of the new subview with the correct vertical offset? You need to calculate this from the already added subviews.Stefanf

1 Answers

0
votes

I found the solution which seems to me be really easy and working correctly so far. I used NSTableView instead of `NSScrollView' alone and I just flipped the tableView overriding method:

- (BOOL)isFlipped{
  return NO;
}

I'm returning NO because NSTableView is flipped itself. I appreciate any comment if it's not so good idea to do it like this.