我正在为iOS 11的应用程序进行更新,但遇到了一些无法理解的问题。我的视图控制器通过编程方式创建所有子视图。
第一个子视图是ImageView。在其上方,我添加了一个UIScrollView。在滚动视图中,有一个UIView,其中包含一个标签。我使用SnapKit进行自动布局约束。
iOS 9和iOS 10都很好 - 没有问题。然而,在iOS 11中,它看起来正常,直到我在滚动视图上“下拉”。与iOS 9和10弹回到其原始位置不同,它停留在滚动状态,就像插入物实际上是其2倍一样。
第一个子视图是ImageView。在其上方,我添加了一个UIScrollView。在滚动视图中,有一个UIView,其中包含一个标签。我使用SnapKit进行自动布局约束。
iOS 9和iOS 10都很好 - 没有问题。然而,在iOS 11中,它看起来正常,直到我在滚动视图上“下拉”。与iOS 9和10弹回到其原始位置不同,它停留在滚动状态,就像插入物实际上是其2倍一样。
// Scroll View
myScrollView = UIScrollView()
myScrollView.contentInset = UIEdgeInsetsMake(scrollInsetHeight(), 0, 0, 0)
myScrollView.backgroundColor = barBackgroundColor
myScrollView.isUserInteractionEnabled = true
self.view.addSubview(myScrollView)
myScrollView.snp.makeConstraints {
make in
make.edges.equalTo(self.view)
}
// Content View
contentView = UIView()
contentView.isUserInteractionEnabled = true
myScrollView.addSubview(contentView)
contentView.snp.makeConstraints {
make in
make.edges.equalTo(myScrollView)
make.width.equalTo(self.view)
}
// Label
let lbl = UILabel()
lbl.text = "..."
lbl.font = UIFont(name: "OpenSans", size: 17)
lbl.textColor = .white
lbl.numberOfLines = 0
contentView.addSubview(lbl)
lbl.snp.makeConstraints {
make in
make.top.equalToSuperview().inset(20)
make.left.right.equalToSuperview().inset(20)
}
// Resize Content
contentView.snp.makeConstraints {
make in
make.bottom.equalTo(lbl.snp.bottom).offset(20)
}