scrollView的底部内容不响应触摸事件

时间:2017-02-06 06:42:03

标签: ios uiscrollview subview

我有滚动视图。在侧滚动视图中,我有一个容器视图,其中包含尾部,前导,顶部和底部约束以及相等的高度。我动态添加视图。我在

中更新了内容大小
  

viewWillLayoutSubviews如下。

override func viewWillLayoutSubviews() {
        self.scrollView.contentSize = CGSize(width: self.contentView.frame.width, height: self.contentView.frame.height)
        self.contentView.frame = CGRect(x: self.contentView.frame.minX, y: self.contentView.frame.minY, width: self.contentView.frame.width, height: 2500) // code to update the contentView's frame where 2500 is a dummy value
        self.contentView.clipsToBounds = true
    }

现在我可以滚动到容器视图的最后一个子视图。但问题是最后3个子视图没有响应触摸事件。

我尝试了以下方法,但失败了。

  • 还更新了containterView的框架
  • 还更新了scrollview的框架

没用。 请帮帮我。

1 个答案:

答案 0 :(得分:1)

 func updateFrame() {
            self.scrollView.contentSize = CGSize(width: self.contentView.frame.width, height: self.contentView.frame.height)
    self.contentView.translatesAutoresizingMaskIntoConstraints = false
            self.contentView.frame = CGRect(x: self.contentView.frame.minX, y: self.contentView.frame.minY, width: self.contentView.frame.width, height: 2500) // code to update the contentView's frame where 2500 is a dummy value
            self.contentView.clipsToBounds = true
        }

试试这个。 我假设你的滚动视图比内容视图大