0

This answer: https://stackoverflow.com/a/25898949/1364053 is suitable for my problem to some extent. What I need is there are three views in my container view.

The middle one is a scroll view. If I pin height and width of all three views and use the ratio method as described in the above link, all works fine.

But I need the middle scrollview to grow to some extent, let's say the current height of the scroll view is 30, If the device height is increased it should grow to a max of 40 but not more than that (<= constraint).

Ok..So I tried giving two constraints to the middle view. The <= constraint has higher priorty (750) than the = constraint (250).. but when the screen size is increased.. the height stays the same. enter image description here

enter image description here

Community
  • 1
  • 1
nr5
  • 4,228
  • 8
  • 42
  • 82
  • have you tried adding that constraint? just add the height limit to it and give it a higher priority than the actual proportional height constraint. That way it will be of some height but always <= your specified upper bounds. – luk2302 May 17 '15 at 09:43
  • Correct me If I understood it wrong.. I should add two height constraints.One with equal height and other with <= height.. and the <= should have more priority than the = one? – nr5 May 17 '15 at 17:11
  • Yes, Xcode will try so satisfy all of them and in case of conflicting ones, prioritize them based on your settings. That will result in the desired behaviour. – luk2302 May 17 '15 at 17:15
  • No luck.. please check the edited question – nr5 May 17 '15 at 17:26
  • I thought you used the "ratio method"!? Your current constraint settings don't look like that... – luk2302 May 17 '15 at 17:29
  • ratio method is there but since the views are of different height.. Some constant has to be added.. check the edited question.. I have added the image – nr5 May 17 '15 at 17:31
  • here is good tutorial check it http://makeapppie.com/2014/07/26/the-swift-swift-tutorial-how-to-use-uiviews-with-auto-layout-programmatically/ – Memon Irshad May 18 '15 at 05:26
  • I don't think the link addresses my problem. – nr5 May 18 '15 at 08:53

1 Answers1

0

Sample.xib The uploaded xib might help you.

Constraints screenshot

BangOperator
  • 4,377
  • 2
  • 24
  • 38