Here is a quick question about something which works, but could be written much better. I have a UIScrollView
and a list of objects laid out inside, one under the other. Everything is done during viewDidLoad()
and the placement of the objects uses Auto Layout
. Here is what I do to set the contentSize
height of the UIScrollView
to its appropriate value.
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
globalView.contentSize = CGSize(width: globalView.frame.width,
height: globalView.frame.height * 1.59)
}
It works, but the arbitrary value 1.59 has obviously been decided by me trying a few possible values. What is the proper way to compute the contentSize in such a case? I am doing everything programmatically. Searching the net didn't lead me to any simple and clear answer, so eventhough it may be a somewhat duplicate question I decided to reformulate it.