Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
774 views
in Technique[技术] by (71.8m points)

xcode - How do you use auto layout in a scroll view?

So I'm using a UIScrollView in a view controller in the latest Xcode. I have buttons inside the scroll view. When I run the application, the scroll view disappears. Can anyone tell me what is causing this and how the auto layout tools work?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Follow these steps, enter image description here

  1. Take scroll view and set constraints (leading, trailing, top, bottom) with respect to the parent view. And set some background color to it so that it will visible at run time.

  2. Take UIButton and place it over scrollview, and then set constraints for your button (leading, trailing, top) with respect to the scroll view, and also set the width and height constraints for button ,and also some background color to button so that it will visible at runtime.

Note: The hirearchy of your contents should be like this- -parentView -ScrollView -button

please let me know if anything is not clear.

Thanks.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...