kiewic
kiewic

Reputation: 16390

UIScrollView scrolling stops working after adding width and height constraints to its content

I have an UIImageView within a UIScrollView, and scrolling works fine when I add trailing, leading, top and bottom constraints to the UIImageView. However, the image in the UIImageView can be very large, and I want it to always display as a 646x537 fixed size image regardless of the picture assigned to it.

Without any extra constraint, the UIScrollView grows as large as the original picture. So, I added width and height constraints to the UIImageView, but then, UIScrollView scrolling is not working anymore, even when the content is still larger than the the view controller.

Xcode navigator

Xcode storyboard

Any idea what am I missing?

Upvotes: 0

Views: 103

Answers (1)

Glorfindel
Glorfindel

Reputation: 22631

This is the wrong one. This one determines the content size of your UIScrollView, and therefore whether it scrolls or not. It should be set to +50, to be consistent with the other constraints.

enter image description here

Upvotes: 2

Related Questions