My Scrollview wont scroll ios


My Scrollview wont scroll ios



I have a view and inside of that view i put a scroll view.



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.



I already give this constraint



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)



The image





please share the screenshot for storyboard view also
– Van
Jul 2 at 11:14




3 Answers
3



Put a view inside scroll view,and assign the wanted height to the view also,top= zero,bottom=zero,left,right= to the scroll ,your scroll view wont scroll if everything is being resized according to the phone



Make your label to fit its content by selecting the label and pressing 'Cmd' + '='. So that it will adjust its size as per the contents added. Also make sure to set number of lines to 0 (to wrap the contents).



As I tried with your mentioned constraint and extra is fit content.
Result:
/Users/admin/Desktop/test.png



Hope it helps...!!!



Just add "Horizontally in Container" constraint to the label.
If Height constraint was not defined, Leading, Trailing constraints works only after "Horizontally in Container" constraint's added.





Why? What will this do? Please give more context to your answer.
– Ashley Mills
Jul 2 at 9:46





If Height constraint was not defined, Leading, Trailing constraints works only after "Horizontally in Container" constraint's added.
– Dilmurat Abduqayyum
Jul 2 at 10:09





Please update your answer and then I can remove the downvote
– Ashley Mills
Jul 2 at 10:10






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.

Popular posts from this blog

Rothschild family

Cinema of Italy