我有一个调用另一个视图的方法。 我想在图像连续一段时间后调用此方法。
这种类型的方法在UIButton = touchDown(),touchup()中找到。
触摸事件中是否有任何方法可以在图像视图中查找连续触摸。
请帮助我。
提前致谢
您可以将以下事件用于 UIIMAGEVIEW:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
您可以使用
点击手势,您可以看到我在此线程中写的答案。在此,您可以设置触发事件所需的点击次数。希望这对你有帮助。
假设你想计算触摸(连续像双击)
- (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
}
}
}