1

I have a UIScrollView attached to a UIViewController that has help text in it. I set the height of the view inside a script but it can just be scrolled horizontally even though I set the labels to multiple lines. I want to be able to scroll down to be able to see the rest of the help text.

In other words, how can I enable vertical scrolling in a UIScrollView?

import UIKit

class HelpController: UIViewController {

@IBOutlet var scrollView: UIScrollView!

override func viewDidLoad() {

    super.viewDidLoad()

    scrollView.contentSize = CGSize(width: view.frame.size.width, height: view.frame.size.height)

}
}

enter image description here

TheLukeGuy
  • 170
  • 2
  • 13
  • 1
    I don't think you should be setting contentSize width. Refer this - https://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/ – Rakesha Shastri Jul 11 '18 at 04:07
  • @RakeshaShastri Thank you, that solved it. If you post an answer to this question, I'll mark it as solved. – TheLukeGuy Jul 11 '18 at 13:22

1 Answers1

2

I don’t think you should be using frames for dynamic content. Try with autolayout like how this guide says

https://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/

Rakesha Shastri
  • 11,053
  • 3
  • 37
  • 50