ios 8 - 水平滚动视图的按钮拦截平移事件 - 滚动不起作用
问题说明
我有一个带有一行按钮的水平滚动视图.除非我非常快速地滑动,否则滚动视图不会滚动.
I have a horizontal scroll view with a line of buttons. The scroll view will not scroll unless I do an extremely fast swipe.
如果我将按钮设置为 userInteractionEnabled = NO,则滚动按预期工作,但当然,按钮根本不起作用.
If I set the buttons to userInteractionEnabled = NO, then the scrolling works as expected, but of course, then the buttons don't work at all.
此应用在 iOS 7 及之前的版本中运行良好.这似乎是 iOS 8 的功能".我确实注意到我可以捕获按钮的拖动事件,但我不知道如何将其重定向回滚动视图.
This app worked fine in iOS 7 and before. It seems to be a iOS 8 "feature". I did notice that I can catch the button's drag event, but I don't know how to redirect it back to the scrollView.
我想我需要用 UIView 替换我的按钮并自己管理事件,但如果有人有其他想法或解决方案,我将不胜感激.
I'm thinking I'll need to replace my buttons with UIViews and manage the events myself but I'd be grateful if someone has other ideas or solutions.
正确答案
我发现在 iOS 8 中,UIScrollView 的底层 UIPanGestureRecognizer 不尊重 UIScrollView 的 delaysContentTouches 属性.我认为这是一个 iOS 8 错误.这是我的解决方法:
I found that in iOS 8, the UIScrollView's underlying UIPanGestureRecognizer is not respecting the UIScrollView's delaysContentTouches property. I consider this an iOS 8 bug. Here's my workaround:
theScrollView.panGestureRecognizer.delaysTouchesBegan = theScrollView.delaysContentTouches
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangicbac
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
使用c++17更新时出现G++编译器警告
it1352 06-18 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
复制文件夹/文件而不修改属性?
it1352 07-15 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
Reaction本机IOS Safari没办法打开页面,因为该地址在有效登录后无效
it1352 06-07