After appending last view with elements (which is inside scroll view) the scroll view height is not changing, so I cannot scroll to bottom of content
Steps which I done:
- Added UIScrollView view, set top, right, bottom and left align to 0
- Added UIView, set top, right, bottom and left align to 0
- From View inside scroll view: set equal width and equal height to the main view (the view that holds the scrollview)
- For First View added constraints:
Top Constraint to container view: 20. Left Constraint: 8. Right
Constraint: 8. Bottom Constraint: Standard. Height: 320 - For Second View added constraints: Top Constraint to container view: Standard. Left Constraint: 8. Right Constraint: 8. Bottom Constraint: Standard
So it looks like:
After this I add manually labels to last View:
class SecondViewController: UIViewController {
@IBOutlet weak var testView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
var yPos = 20
for i in 0...20 {
let testLabel = UILabel(frame: CGRect(x: 0, y: yPos, width: 200, height: 20))
testLabel.text = "test \(i)"
testLabel.font = UIFont(name: "Arial", size: 11)
testView.addSubview(testLabel)
yPos += 20
}
}
}
As you can see I can only see labels 1-9, rest are not visible because scrolling to bottom is not possible
It is problem because I mixing auto layout with programmatically added labels to View? How I can resolve this issue?