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: 等来实现
// // 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
如对本文有疑问, 点击进行留言回复!!
Codeforces Round #657 (Div. 2) C题
hdu2222 Keywords Search(ac自动机模板-kuangbin)
IOS开发控件视图day08:监听文本框状态设置按钮状态不可点击且变灰
网友评论