【发布时间】:2016-08-14 06:35:39
【问题描述】:
在图片中你可以看到我的 Storyboard 的结构: View -> ScrollView -> ContentView (view) -> Views 。蓝色图像中的按钮出现在手机屏幕外,当我将滚动条移至该按钮时,该按钮未检测到点击。
我在许多论坛上阅读并添加了以下内容:
scrollView.userInteractionEnabled = Bool(true);
scrollView.exclusiveTouch = Bool(true);
scrollView.canCancelContentTouches = Bool(true);
scrollView.delaysContentTouches = Bool(true);
在 StoryBoard 中,我将 ScrollView 标记为“延迟内容触摸”,并将按钮标记为“启用用户交互”
我不知道该怎么办。
【问题讨论】:
-
你确定你的Scroll View里面的Content View的内容大小等于你的Scroll View的内容大小吗?
-
检查该按钮的框架。如果您设置了约束,请确保它们设置正确。
-
你不觉得“Bool(true)”有点矫枉过正吗?你可以把“真”....
-
将按钮放在z-index最高的位置,尝试不同分辨率的手机。所以你可以找出,如果它是一个约束问题
-
解决方案:@vishaluae 评论内容视图的大小。在我的 StoryBoard 中,内容视图有一个约束“contenView.height = parent.height (parent = ScrollView)。但我在代码中更改了 scrollView 的高度。我删除了约束并且它起作用了!
标签: ios swift uiscrollview uistoryboard