UIScrollview with auto layout
I am afraid of UIScrollView now.
"descriptionLabel" and "genresLabel" will increase the height at runtime, and the gap between participants will widen. So I need a scroll function to see the shortcuts to the actors.
I set the height of the contentView to a height constraint equal to the view with a priority of 250 and hoped the height would increase automatically if needed.
Nothing really happens and scrolling is not possible.
How can I automatically increase the height of the contentView in the auto layout context?
source to share
You have to make the ContentView height flexible so that it grows and the scroll content grows accordingly. Check out the attached screenshots. Increase the limit of the bottom label (which is 495), the size of the scroll content will be automatically increased.
Here is a Sample Source Code
source to share
Is your label Actors the final piece of this show? If after that we fix both Actors: and asdfas ... top, bottom and left. Now for the lower value, set "Constant" to "Use default value". Also fix the top-most item (here maybe "No network connection!"), And set its "Constant" to "Use default". Try this and let me know if it works!
I tried what I told you. Having images of the same. Hope it helps!
For Actors shortcut restrictions:
and for constraints the asdfas labels are given in the following image:
source to share
Just check this link, just write this to add content view height: -
override func viewDidLayoutSubviews()
{
let scrollViewBounds = scrollView.bounds
let containerViewBounds = contentView.bounds
var scrollViewInsets = UIEdgeInsetsZero
scrollViewInsets.top = scrollViewBounds.size.height/2.0;
scrollViewInsets.top -= contentView.bounds.size.height/2.0;
scrollViewInsets.bottom = scrollViewBounds.size.height/2.0
scrollViewInsets.bottom -= contentView.bounds.size.height/2.0;
scrollViewInsets.bottom += 1
scrollView.contentInset = scrollViewInsets
}
source to share
It's hard to figure out what's wrong with your layout, so I created a test project with 2 growing shortcuts, everything works fine, maybe you can find out what is wrong in your constraints :)
https://www.dropbox.com/s/j8269c03b32gra5/scrollview-test.zip?dl=0
Build my project and click the More Text button to dynamically add text to the labels in the scrollview
source to share