【发布时间】:2021-04-13 08:21:26
【问题描述】:
目前,我有如下布局设计
[Safe Area]
[Scroll View (In green color)]
[Custom View (In red color)]
[Horizontal Stack View]
[Button 1]
[Button 2]
[Text View]
[Bottom Toolbar]
它被设计成,随着[Text View]的内容增长,用户可以垂直滚动[Text View]和按钮组([Horizontal Stack View])
应该是这样的
我们认为我们在[Custom View] 和[Scroll View] 之间使用了正确的约束
Custom View.top = Content Layout Guide.top
Custom View.trailing = Content Layout Guide.trailing
Custom View.leading = Content Layout Guide.leading
Custom View.bottom = Content Layout Guide.bottom
Custom View.width = Frame Layout Guide.width
我们从 Xcode 得到的一个警告是
Scrollable content size is ambiguous for "Scroll View".
因此,为了避免这种情况,我们需要添加
Custom View.centerX = Frame Layout Guide.centerX
Custom View.centerY = Frame Layout Guide.centerY
但是,当我们执行应用程序时,只有[Text View] 是垂直可滚动的,当文本内容增长时。 顶部按钮组保持不变。
我们尝试禁用 [Text View] 本身的滚动行为。同样,当文本内容增长时,整个页面都不可滚动。
你知道如何解决这个问题,以便当文本内容增长时,顶部按钮组可以与文本视图一起滚动?
演示位于https://github.com/yccheok/ios-tutorial/tree/learn-scroll-view/NavigationController
【问题讨论】:
标签: ios swift uiscrollview uitextview