UITextView not visible on UIScrollView

前端 未结 3 1886
难免孤独
难免孤独 2020-12-22 09:12

Ok, so what I have is a UIScrollView that is constrained to all four sides of the main view, centered both vertically and horizontally, and set to have equal width and heigh

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-22 09:42

    Avoid putting all your subviews directly inside the scrollView. The autolayout will break apart. You need to :

    • Add a UIView inside the UIScrollView, with constraints 0-0-0-0 to leading-top-bottom-trailing to the UIScrollView, and put all your subViews inside that UIView.

    After that, you need to set the contentSize of your UIScrollView by code.

    Also, you can:

    • add missing constraints to see what is missing.

    • The left panel in UIStoryBoard (Document Outline), you can press the red arrow showing up to see what is missing or conflicting.

    Check out Apple documentation for more details.

提交回复
热议问题