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

The bottom content of the scrollView is not not responding to touch events

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

中更新了内容大小

viewWillLayoutSubviews as follows.

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 个子视图没有响应触摸事件。

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

没用。 请帮助我。

 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
        }

试试这个。 我假设您的滚动视图大于内容视图