我有一个 ScrollView 和其中的容器 View 。 UIButtons 位于容器 View 内部。 当我运行程序时,位于 ScrollView 末尾的 UIButtons 无响应。 UITextFields 是响应式的。 然而,在调整框架后,我确保 UIScrollView 和容器 View 的 origin 和 hightXwidth 都匹配。我用打印语句检查了它。 一些设置:
scrollView.isExclusiveTouch = true
scrollView.delaysContentTouches = false
scrollView.isUserInteractionEnabled = true
ScrollView 的内容大小:
let hightForScrollMenu: CGFloat = 120
scrollView.contentSize = CGSize(width: scrollView.frame.size.width, height: scrollView.frame.size.height+hightForScrollMenu)
检查时:
viewInsideScrollView.frame.size.height = scrollView.frame.size.height
print("Zhenya: ScrollView's frame height is:\(scrollView.frame.size.height) and its origin is \(scrollView.frame.origin)")
print("Zhenya: ViewInsideScrollView's frame heigt is: \(viewInsideScrollView.frame.size.height) and its origin is \(scrollView.frame.origin)")
View Controller 属性:
主视图属性和约束:
ScrollView 属性和约束:
容器 View 属性和约束:
最佳答案
容器 View 是红色 View ?嗯,那么显然按钮在它的外面。其 super View 之外的按钮是不可点击的。
关于ios - ScrollView 中的 UIButton 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41772877/