视图控制器中的所有内容都被推到了顶部

时间:2015-04-21 20:26:59

标签: ios swift view uiscrollview autolayout

我有一个滚动视图,里面有6个视图控制器(并排)。由于某种原因,第4个视图控制器将所有内容放在最顶端。请参阅下面的图片。

这里发生了什么: Happening

这里应该做什么: Expected Behaviour

我尝试删除故事板中的所有约束并将它们放回去,但它并没有改变。这里是我用来将视图控制器放在滚动视图中的代码(我使用的是PureLayout):

self.addChildViewController(vc1)
self.scrollView.addSubview(vc1.view)
vc1.view.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Right)
vc1.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc1.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

self.addChildViewController(vc2)
self.scrollView.addSubview(vc2.view)
vc2.view.autoPinEdge(ALEdge.Left, toEdge: ALEdge.Right, ofView: vc1.view)
vc2.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc2.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

self.addChildViewController(vc3)
self.scrollView.addSubview(vc3.view)
vc3.view.autoPinEdge(ALEdge.Left, toEdge: ALEdge.Right, ofView: vc2.view)
vc3.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc3.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

self.addChildViewController(vc4)
self.scrollView.addSubview(vc4.view)
vc4.view.autoPinEdge(ALEdge.Left, toEdge: ALEdge.Right, ofView: vc3.view)
vc4.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc4.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

self.addChildViewController(vc5)
self.scrollView.addSubview(vc5.view)
vc5.view.autoPinEdge(ALEdge.Left, toEdge: ALEdge.Right, ofView: vc4.view)
vc5.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc5.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

self.addChildViewController(vc6)
self.scrollView.addSubview(vc6.view)
vc6.view.autoPinEdge(ALEdge.Left, toEdge: ALEdge.Right, ofView: vc5.view)
vc6.view.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Left)
vc6.view.autoMatchDimension(ALDimension.Width, toDimension: ALDimension.Width, ofView: self.scrollView)
vc6.view.autoMatchDimension(ALDimension.Height, toDimension: ALDimension.Height, ofView: self.scrollView)

这是" B"的限制因素。按钮例如: Constraints

故事板中的视图控制器: view controller

imageview的约束: constraints

0 个答案:

没有答案