我注意到UIScrollView
可能再次被打破。我使用OS X 10.11.1
和Xcode 7 (from AppStore)
或Xcode 7.1 beta
。 AutoLayout完成其工作后,contentOffset
属性不在origin
的{{1}}。
有人可以确认这个问题吗?
然而,我设法解决了问题,但这不是它应该如何:
UIScrollView
以下是重现此问题的方法:
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
self.scrollView.contentOffset = CGPoint(x: 0, y: -self.scrollView.frame.origin.y)
/* if you need a different position, I suggest to safe the
contentOffset inside viewWillLayoutSubviews and calculate the offset here */
}
更新:报告并填充了雷达:22770934
UPDATE2:问题已解决。
答案 0 :(得分:0)
我在视图调试器的帮助下找到了解决方案。
添加这些缺失的约束,一切都会好的:
self.containerView.topAnchor.constraintEqualToAnchor(self.scrollView.topAnchor).active = true
self.containerView.leftAnchor.constraintEqualToAnchor(self.scrollView.leftAnchor).active = true
self.containerView.rightAnchor.constraintEqualToAnchor(self.scrollView.rightAnchor).active = true
self.containerView.bottomAnchor.constraintEqualToAnchor(self.scrollView.bottomAnchor).active = true
// actually the debugger showed two different constraints, but this had no effect on the functionality, correct me here if I am wrong
// trailing and button constraints where like this:
// self.scrollView.trailingAnchor.constraintEqualToAnchor(self.containerView.trailingAnchor).active = true
// self.scrollView.bottomAnchor.constraintEqualToAnchor(self.containerView.bottomAnchor).active = true