touchesBegan: withEvent: 不执行解决
2015-11-20 18:00
337 查看
touchesBegan: withEvent: / touchesMoved: withEvent: / touchesEnded:
withEvent: 等只能被UIView捕获(如有问题请指出对请指出,路过的大牛请勿喷),当我们创建
UIScrollView 或 UIImageView
时,当点击时UIScrollView 或 UIImageView 会截获touch事件,导致touchesBegan: withEvent:/touchesMoved:
withEvent:/touchesEnded: withEvent: 等方法不执行。解决办法:当UIScrollView 或 UIImageView 截获touch事件后,让其传递下去即可(就是传递给其父视图UIView)
可以通过写UIScrollView 或 UIImageView 的category 重写touchesBegan: withEvent: / touchesMoved:
withEvent: / touchesEnded: withEvent: 等来实现
withEvent: 等只能被UIView捕获(如有问题请指出对请指出,路过的大牛请勿喷),当我们创建
UIScrollView 或 UIImageView
时,当点击时UIScrollView 或 UIImageView 会截获touch事件,导致touchesBegan: withEvent:/touchesMoved:
withEvent:/touchesEnded: withEvent: 等方法不执行。解决办法:当UIScrollView 或 UIImageView 截获touch事件后,让其传递下去即可(就是传递给其父视图UIView)
可以通过写UIScrollView 或 UIImageView 的category 重写touchesBegan: withEvent: / touchesMoved:
withEvent: / touchesEnded: withEvent: 等来实现
// // UIScrollView+UITouch.m // // // Created by MLS on 15/11/20. // Copyright © 2015年 mls. All rights reserved. // #import "UIScrollView+UITouch.h" @implementation UIScrollView (UITouch) - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { // 选其一即可 [super touchesBegan:touches withEvent:event]; // [[self nextResponder] touchesBegan:touches withEvent:event]; } @end
相关文章推荐
- Android中的矩阵转换 (Matrix转换)
- 迅雷公布2015第三季度财报:净亏损330万美元
- [LeetCode-28] Implement strStr(KMP 字符串匹配)
- 动画特效十八:粘性动画2
- uboot中挂载U盘,利用FAT文件系统读写U盘文件
- Windows AdEasyGo支付SDK接入
- UIScrollView的delegate方法妙用之让UICollectionView滑动到某个你想要的位置
- Spring常用注解
- Xms Xmx PermSize MaxPermSize 区别
- maven web报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- win10安装mysql5.7 net start mysql拒绝访问 mysql配置文件修改不生效
- ios--uitextfield动态限制输入的字数
- 安卓动态曲线的绘制
- Base64使用案例
- C语言开发总结(二)
- hdoj 素数判定
- Tomcat内存设置详解
- 如何使用GitHub管理代码
- windows系统快捷操作の高级篇
- 批处理删除指定天数之前的文件和相应目录下的空文件夹