ScrollView's automatic layout is a little cumbersome, but it's also a regular one,
The following is a fixed practice for adding constraints to vertical sliding only ScrollView
1. Add a label to the view of the controller and name it anchor
2. Add a constraint to anchor: 0 (indicates the view of anchor and Controller)
3. Add a ScrollView
4. Add the same constraint to the ScrollView: 0(indicating that the ScrollView is also associated with the controller's view)
here ,scrollview two key constraints (2 constraints determine the horizontal and vertical scrolling range)
5. Add a label to ScrollView, named BG1 (you can directly determine the scroll range of the ScrollView by using the label)
6. Add a constraint to the BG1, bg1 to the right and left all 0, and a height of 35
Here are the key points :
At the same time check anchor and BG1, let them equal width equal width;
(Note: The goal is to make the horizontal scrolling range of the ScrollView exactly the same as the screen width, i.e. the horizontal direction is not scrollable)
BG1 from 999
(Note: The purpose is to determine the vertical scrolling range of the ScrollView, which can be adjusted arbitrarily , this constraint can also be added to the bottom of any scrollview in a child element)
Here is: Xib interface, if you do not understand the place can be presented below
Automatic layout of Ios_scrollview