How to fix “Scrollable Content Size Ambiguity” in Xcode 11 (iOS 12, iOS 13) using Auto Layout

后端 未结 8 1870
独厮守ぢ
独厮守ぢ 2020-12-23 15:49

When using Auto Layout, I am unable to set up a simple UIScrollView in my view controller in Xcode 11 beta. I know that I must constrain the scroll view to the edges, and th

相关标签:
8条回答
  • 2020-12-23 16:49

    For me, initially the Content Layout Guides is in disabled state by default in ScrollView. So I just enabled and disabled the Content Layout Guides then the error disappeared automatically.

    0 讨论(0)
  • 2020-12-23 16:50

    I stacked with that problem as well. Found a good guide that helped me:

    https://useyourloaf.com/blog/scroll-view-layouts-with-interface-builder/

    Basically what you need is 9 constraints (assuming you want to scroll only vertically):

    1-4: ScrollView to Superview (top, bottom, leading, trailing). Make sure to connect it to parent view and not to safe area.

    5-8: Content view to Content Layout guide (top, bottom, leading, trailing).

    1. Content view Width equals width to Frame Layout Guide.
    0 讨论(0)
提交回复
热议问题