mike vorisis mike vorisis - 1 month ago 15
iOS Question

Dynamic Scrollview Swift

I have made a

Button
which generates
TextFields
and I want a
ScrollView
so if I'd add too much
TextFields
I could scroll and write to them. I also have a
Button
at the bottom of my view and I want this to be visible all the time. (I don't mind if only
TextFields
will be inside the
ScrollView
or the whole view except my bottom button).

This is how it looks like:

Answer

You have to set the height constraint on your TextFields. Without that, the scrollView can't figure out its contentSize. After you set the heights, the scrollView will adapt accordingly.

Also, I would use a UIView and give a fix height for it and place the TextFields inside of the UIView.