I want to create a simple view hierarchy in a Swift project that has a UIScrollView which should act as an expandable container to the subviews which are: UILabel, UITextView and a Button.
The catch here is that I am doing it all programmatically using visual format language and cannot do it in Interface Builder. My code below displays a scrollview, however it cannot scroll down to show the views which are below it and the views themselves are not sized correctly. It is static. Also the subviews are not expanding to fill up the screen.
I want to display a scrollview which is fullscreen size and also its subviews fill the screen horizontally with varying heights depending on what size I set. They currently only are around 200pt wide which is unusual.
viewDidLoad() {
view.addSubview(scrollView)
//This function is a convenience function which applies constraints
view.addConstraints(withFormat: "H:|[v0]|", toViews: scrollView)
view.addConstraints(withFormat: "V:|[v0]|", toViews: scrollView)
//Here I add the 3 subviews mentioned above
scrollView.addSubview(nativeText)
scrollView.addSubview(mnemonicDescription)
scrollView.addSubview(addButton)
//Here I apply constraints using format language
scrollView.addConstraints(withFormat: "H:|[v0]|", toViews: foreignText)
// Note that this should make foreignText expand the full width. It doesn't, its very small
//I continue to add subviews with horizontal and vertical constraints however they do not fill the container view as expected.
}