我有一个UIImageView
with a UILongPressGestureRecognizer
无论我如何配置手势识别器,似乎都不会检测到长按手势。但是,如果我把它换成UITapGestureRecognizer
, that工作得很好。可能发生了什么?
这就是我配置我的方式UILongPressGestureRecognizer
:
UIImageView* cellView = (UIImageView*)[view viewWithTag:5];
UILongPressGestureRecognizer* longPressGestureRec =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(cellLongPress:)];
longPressGestureRec.numberOfTapsRequired = 1;
longPressGestureRec.numberOfTouchesRequired = 1;
longPressGestureRec.minimumPressDuration = 0.4;
[cellView addGestureRecognizer:longPressGestureRec];
[longPressGestureRec release];
这是什么cellLongPress
好像:
-(void)cellLongPress:(UILongPressGestureRecognizer*)recognizer
{
// This never gets called.
NSLog(@"someone long pressed me");
}
很简单,对吧?不过,到目前为止还没有让它发挥作用。有任何想法吗?
The numberOfTapsRequired
被设定为1
这意味着用户必须点击一次before开始长按(手指向下、手指向上、手指向下 0.4 秒,手势识别)。
Change numberOfTapsRequired
to 0
(这是默认值)。
对于该属性,文档只是说:
手势所需的点击视图次数
认可。
但在评论中UILongPressGestureRecognizer.h
, 它说:
按下手势之前所需的完全点击次数
认可的
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)