Reputation: 2832
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).
Upvotes: 1
Views: 5112
Reputation: 377
You have to set the height constraint on your TextField
s. 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 TextField
s inside of the UIView
.
You can also use scrollView.contentSize = CGSize(width: expectedWidth, height: expectedHeight)
Upvotes: 4
Reputation: 7892
These steps help you to design screen according to your requirement :
ScrollView
and provide height and width accordingly ScrollView
not within the ScrollView
ScrollView
ScrollView
provide its l
Left , Right , Top constraint .ScrollView
and by pressing Control + drag mouse
to Button ( below of Scrollview) and set vertical spacing between ScrollView and ButtonNote - As AutoLayout
works differently with ScrollView
so always set constraint of all control within it from Order : Top To Bottom
Hope it helps you to fix this issue . Feel free to comment if still any confusion.
Thanks.
Upvotes: 1