How can I use AutoLayout to place view exactly above other?

283 views Asked by At

I have a layout which has a UIScrollView which has certain constraints with its container (the root view).

enter image description here

Now I want to place an UIImageView exactly above this scrollview and place a large image inside it, which should be scaled accordingly. I set up constraints between the imageview and the scrollview to align their centers and make them equally wide and high. The image shows, what I would like to achieve.

enter image description here

What I would like is that the scrollview is fixed before the imageview is placed so that the scrollview determines the frame of the imageview on top, but what seems to happen is that the imageview (whose image resolution is too large for the screen) determines the frame of the scrollview, resulting in complete mayhem.

enter image description here

How can I make it so the scrollview gets the frame shown in the first image and the imageview is properly positioned on top of it?

EDIT: I uploaded the storyboard here (without constraints on the image view as they don't work)

0

There are 0 answers