【发布时间】:2019-08-19 08:30:29
【问题描述】:
我有一个scrollView,其中有一个stackView。 scrollView 被限制为 rootview。堆栈视图将显示一个 xib 视图。
xib 视图的长度都不同。
xib 视图标记为simpleVC0 和simpleVC1。 simpleVC0的长度是2500,simpleVC1的长度是1000。
我的问题是,当 xib 视图显示在堆栈视图中时,scrollView 的长度不会更改为显示的 xib 视图的长度。
就像呈现 xib 视图但滚动视图被锁定在特定长度一样。
这是simpleVC0 xib 视图。运行时紧随其后。当我尝试滚动时,它不允许我滚动到 xib 视图的底部。它似乎在一定长度上切断了 xib 视图。
说这可能是一个可能必须在代码中解决的问题是对的吗?还是它可以通过约束来解决。
我已经尝试过自动布局约束,但它们没有奏效。
我在所有四个方面都将scrollView 限制为rootview。
加载根视图时,使用以下代码建立 xib:
//Different subViews for ingredients and steps
if counter == 0 {
simpleViewX = SimpleVC0().view
simpleViewY = SimpleVC1().view
stack.addArrangedSubview(simpleViewX)
stack.addArrangedSubview(simpleViewY)
}
视图是通过更改分段视图控制器的值而显示的隐藏视图。如下图:
@IBAction func tabselected(_ sender: Any) {
switch (sender as AnyObject).selectedSegmentIndex {
case 0:
simpleViewY.isHidden = true
simpleViewX.isHidden = false
break
case 1:
simpleViewX.isHidden = true
simpleViewY.isHidden = false
break
case 2:
//calledvideo in array is the value of the counter.
calledVideo = vids[counter]
geturl()
break
default:
break
}
}
【问题讨论】:
-
显示你是如何加载 xib 内容的。
-
@DonMag 刚刚更新了它以显示如何调用 xib。
标签: xcode constraints scrollview stackview