【问题标题】:Containerview inside scrollview not scrolling滚动视图内的Containerview不滚动
【发布时间】:2020-08-18 14:12:14
【问题描述】:

我的观点是这样的:

superView
-scrollview = CONSTRAINTS(leading: superView, trailing: superView, top: superView, bottom: superView)
--view = CONSTRAINTS(leading: superView, trailing: superView, top: superView, bottom: superView, equalWidth: scrollView, equalHeight[priority: 250]: scrollView)
---collectionView = CONSTRAINTS(leading: view, trailing: view, top: view, height: 50)
---containerView = CONSTRAINTS(leading: view, trailing: view, top: collectionView, bottom: view)

我已经在 scrollview 中搜索了所有关于 containerView 的问题,但都没有解决我的问题。

【问题讨论】:

  • 你给collectionview定高了吗?
  • 是的,collectionview 的固定高度为 50
  • 如何使用 equalHeight[priority: 250]: scrollView.视图高度必须高于滚动视图。
  • 这些约束并不意味着滚动。 view 高度等于scrollview 高度。 collectionview 有 50 个高度,containerview 占据其余空间。要使其可滚动,view 的高度应大于scrollview 的高度
  • @AlexanderGaidukov 是的,我意识到如果我为 containerView 设置约束高度,它现在会滚动,但问题是 containerView 的高度不应该是固定的,因为 containerView 的高度将取决于嵌入的视图

标签: ios swift uistoryboard ios-autolayout xcode-storyboard


【解决方案1】:

我设法通过将嵌入视图设置为 translatesAutoresizingMaskIntoConstraints = false 将其放入 prepareForSegue 来解决此问题

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
 segue.destination.view.translatesAutoresizingMaskIntoConstraints = false
}

我的参考:Sizing a Container View with a controller of dynamic size inside a scrollview

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-09
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多