iBlink iBlink - 1 year ago 122
iOS Question

Xcode Scroll View over full width and height

How can I create a Scroll View over the full width and height in different resolutions (for ex. iPhone 4, iPhone 6)?

What I try:
Select the Scroll View and use Autoresizing to scale it up:
enter image description here

This seems to work at first:
enter image description here

But xcode complains then about constrains errors:

enter image description here

And if I fix them the Scroll View loses its height and width:
enter image description here

What do I do wrong?

Answer Source
  1. Change Size Class to Any Any if it is not.
  2. Select ScrollView and Click Pin button located at bottom.
  3. Fill Top, Left, Bottom and Right Boxes with zero and click all four dashed lines, then click Add 4 Constraints button at bottom in popup.
  4. Now to Resolve the Auto Layout issue, Select Scrollview and Click Resolve the Auto Layout issue button (last) located at bottom and select Update Frames option.


Note: If you want to use ScrollView with autolayout, you need to do some more work. for e.g. Don't put subviews directly into ScrollView. Put UIView in ScrollView as container and put your all subview in it. Follow this tutorial

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download