Search code examples
iosswiftxcodestoryboardhorizontal-scrolling

How to scroll inside of UIScrollView in Xcode Storyboard Editor


I have a horizontally scrolling UIScrollView that runs "off" the screen. See image:

Long text descripton

I want to be able to edit the content more directly in the Storyboard rather than guessing where to put Views etc. As you see in the image above, you can't see the entire text of the UILabel, nor the ImageView at the end, much less anything else I might want to put there.

I'm using Xcode 14.2.


Solution

  • I answered this ten years ago, and in a perhaps better way a few months after, but due to the endless vicissitude of Apple's designs, the procedure has become slightly different, so here's a new answer.

    You can't scroll a scroll view in the storyboard editor. As a workaround, you can make the scene wider, and the scroll view wider, so that you can see all of its content in the storyboard editor.

    1. Select the view controller in the storyboard outline.

      Storyboard outline with View Controller selected.

    2. Open the Size inspector. Change the setting for “Simulated Size” from “Fixed” to “Freeform”.

      The Size inspector for the view controller. The “Simulated Size” pop-up menu is open and the “Freeform” menu item is highlighted.

    3. Increase the width of the simulated size as needed so that you can make your scroll view wide enough to see all its content. Depending on how your constraints (or autoresizing mask) are set up, the scroll view may get wider automatically.