0

I have an IKImageBrowserView inside a NSScrollView.
I added Autolayout constraints to fix the top of the scroll view to the textfield above it and the bottom of the scroll view to the bottom of the window.

The desired behaviour is, that the scroll view (and the IKImageBrowserView with it) will grow and shrink vertically when you grow and shrink the window vertically.

The actual behaviour is, as soon as i added the constraints, the window is no longer vertically resizable.

Why is that? How can I achieve the desired behaviour?

MartinW
  • 4,966
  • 2
  • 24
  • 60
  • 1
    You can examine the constraints by doing `NSArray* c = [window.contentView constraintsAffectingLayoutForOrientation:NSLayoutConstraintOrientationVertical]; NSLog(@"%@", c);`. You could also do `[window visualizeConstraints:c]` to explore interactively. If it doesn't become clear, update your question with the logged constraints. – Ken Thomases Jun 16 '14 at 21:19
  • Thank you! I did not know about these possibilities for diagnosis. I found that two other elements i did not suspect at all were responsible for the problem. – MartinW Jun 16 '14 at 21:38
  • @KenThomases Do you want to add your help for autolayout problem diagnosis as an answer? – MartinW Jun 16 '14 at 21:39

1 Answers1

1

You can examine the constraints by doing:

NSArray* constraints = [window.contentView constraintsAffectingLayoutForOrientation:NSLayoutConstraintOrientationVertical];
NSLog(@"%@", constraints);

You could also do [window visualizeConstraints:constraints] to explore interactively.

See Auto Layout Guide: Resolving Auto Layout Issues – Debugging in Code.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154