使用触摸事件在imageView中进行连续触摸检测..?
我有一个调用另一个视图的方法。我想在图像持续一定时间后调用这个方法。使用触摸事件在imageView中进行连续触摸检测..?
这种类型的方法在UIButton = touchDown(),touchup()中找到。
触摸事件中是否有任何方法在图像视图中查找连续触摸。
请帮我。
在此先感谢
您可以使用这些事件的UIImageView:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
谢谢,但这种方法只在图像视图中找到触摸。我试图检测图像视图上的连续触摸。就像在UIButton touchdown()方法中一样。 – 2012-07-06 08:42:57
touchesBegan和touchesEnd是只有事件 – 2012-07-06 08:55:53
假设你要计算的触摸(连喜欢双击)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
int index =[touch view].tag;
if (touch.tapCount == number && index == imageTag) {
}
}
tapCount将是在很短的时间间隔内持续拍摄水龙头的次数(双击)。如果您想要观看的轻拍计数有较长的延迟(例如5次单击),则无法使用它。或者,你可以记住触摸你的ImageView的,是这样的:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
int index =[touch view].tag;
if(index == imagetag){
if([tempMutableArray count] < definiteTime){
[tempMutableArray addObject:@"any"]
}else{
[tempMutablArray removeAllObjects];
//you can call the method now
}
}
}
什么是“tempMutableArray”在这里.. ?? – 2012-07-06 08:52:21
它应该在头文件中的一个NSMutableArray的实例。代码只是为了给你一个想法,手势识别器也是一个选项 – janusbalatbat 2012-07-06 09:00:20
使用手势识别器 – 2012-07-06 08:33:53