how to make a proper scrollview inside of view with a mutiple lines label in swift
how to make a proper scrollview inside of view with a mutiple lines label in swift
So I want to make a scrollview inside of view but the problem is if i add label with multiple lines in scrollview but The result is the scrollview will stretch to right not enter to multiple lines but in storyboard the label looks fine when i run it on Simulator the label stretch to right.My goal is to make the scrollview scrollable without change the size.I already tried to centre horizontal the textfield and the label but the result i cant scroll vertical the scrollview.
thanks for all the answers
okay i will upload it
– Indra Sen
Jun 29 at 10:26
post you code so will update it
– Pravin Tate
Jun 29 at 10:31
did you set label bottom ?
– Manish Mahajan
Jun 29 at 10:31
you need to set label horizontal to scrollview & need to update constraints of all views so can scrollview can define its scrollable height.
– Saurabh Prajapati
Jun 29 at 10:56
2 Answers
2
Set Label lines to zero and top,left,right,bottom constraints , Don't give constant height.
thanks,ialready did what you tell but now iam facing a new problem.I cant scroll it execpt i click the textfield then i can scroll it
– Indra Sen
23 hours ago
i didn't get your point exactly, you mean when you touch the textfield , keyboard appearing on the textfield you are not seeing the textfield until u scroll up.
– chandra1234
22 hours ago
no,i still can see the textfield and i scroll it.But if the keyboard not appear i cant scroll the scrollview
– Indra Sen
20 hours ago
One thing i can say, height of the scrollview is more than the view then only it scrolls and that too only last(bottom element) element should have bottom to scrollview constraint and remove if any bottom to scrollview constraint is there
– chandra1234
17 hours ago
Lets assume your view hierarchy like this
- View (MainView)
- Scroll View (ScrollView)
- Label (Label)
Set Your Constraint Like This.
Scroll View :-
Leading, Trailing, Top and Bottom To SuperView(MainView)
Label :-
Leading, Trailing, Top and Bottom To SuperView(ScrollView)
Leading and trailing To The Scroll View's SuperView (MainView)
Leading and Trailing Constraints of Label to MainView will prevent Label to expand the width and the height will expand withing the scrollView
thanks,ialready did what you tell but now iam facing a new problem.I cant scroll it execpt i click the textfield then i can scroll it
– Indra Sen
23 hours ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
post your code or storyborad screenshot then we can help you.
– Pravin Tate
Jun 29 at 10:21