Add a ScrollView to existing View

前端 未结 6 1194
野的像风
野的像风 2020-12-09 08:26

I\'m developing a little app in Swift 2.0. I have a View with the following hierarchy:

Now, the elements placed in this view can\'t be displayed entirely in

6条回答
  •  旧巷少年郎
    2020-12-09 08:55

    I had the same issue. I needed to add scrollview to the existing view.But my main container view has a lots of view inside it. And they were connected to each other. So i was afraid. Finally i did it. the process given below.

    1. Duplicate your View (root View). For this first select the root view then press Command + D

    2. Now delete all the child view view inside the root view

    3. Now add a scroll view to the root view and set constraint to 0,0,0,0

    4. Now add the duplicate(That you duplicated) view to the scroll view and set constraints to 0,0,0,,0 also set the height that you want.

    5. Set width of the duplicate view by equal width with the root view.

    6. Now select the viewController, go the size inspector, select free form size. Then set the height that you entered with duplicate view.

    7. You have almost done. Now you have to connect the child view with outlet or action that you gave in the viewController class.

    Thats all.

提交回复
热议问题