0
votes

I have some modal controllers that are UIViews and are not scrolling.

Reading on SO, the apple docs and elsewhere, it seems there are three approaches to fixing this:

  • Multiselect all the elements within the view and then go editor-embedin-UIScrollview.

    change the view to a scrollview in the identity inspector and then add the following line to viewdidload:

    [(UIScrollView *)self.view setContentSize:CGSizeMake(320, 2000)];

    Copy elements to clipboard, delete the uiview, add a new scrollview and copy the elements into the scrollview. Warning - this destroys the positioning of the elements although it does preserve their outlet properties.

However, I have tried all of these and the scrollview still does not scroll.

Is there any other step I am missing?

Thanks in advance for any suggestions.

Edit:

Getting scrollviews to work is not easy and there is much conflicting advice on the web.

I finally got this to work by setting the content size in a separate method as opposed to viewdidload.

  • (void)viewDidLayoutSubviews { self.MainScroll.contentSize = CGSizeMake(320, 1800); }

Thanks as well to Evo for advice on setting all the vertical dimensions correctly and using freeform in the VC size inspector as it won't work if you don't carefully set these.

1

1 Answers

1
votes

If you have EVER enabled autolayout, even if it's disabled now, you need to:

  1. Select the view controller you plan on scrolling
  2. At the bottom right of the storyboard view, click the third button (far right) and then "Reset to Suggested Constraints"
  3. Make sure that all the elements in the scrollview are embedded in the desired positions.

If you are not using autolayout:

  1. Check that the Size of the view controller is set to (320, 2000), or whatever you want.
  2. In the Simulated Metrics of the view controller, you can set the size type to Freeform.
  3. Then in the tab to the right of Simulated Metrics, you can set the width and height to the desired values.

Please comment any concerns