AutoLayout, put all views in the new parent view

I defined all the views and set my restrictions using superview in the view controller, but now I want to put all these children views in Scrollview , I found that all these restrictions disappear. Are there any good ways to make this easier and not reset all of these limitations?

Following the pictures shown below:

Initial restrictions

Now, when I drag all these views into Scrollview , all restrictions disappear

Lack of all restrictions

(sorry these two links are screenshots, I don't have 10 reputation for sending images)

+5
source share
1 answer

just select your UIElements that you want to be a child of UIScrollView. Now go to the editor → Embed In → UIScrollView Now your child viewcontrollers will scroll through scrollview with all the restrictions except for the restrictions that depend on its supervisor. Here is an image of how to select and insert Insert items

Restrictions depending on layout layoutview, you have to do them again using uiscrollview. add the restriction of adding to scrollview with its superview.

+3
source

Source: https://habr.com/ru/post/1271592/


All Articles