Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/100.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 长新闻视图事件_Ios_Objective C - Fatal编程技术网

Ios 长新闻视图事件

Ios 长新闻视图事件,ios,objective-c,Ios,Objective C,我如何检测长按视图的润色事件?例如,当用户按视图超过5秒,然后用手指触摸时 ui长按手势识别器可用于固定时间的按键 我尝试使用: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 但当按下超过2秒时,将调用此函数: - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 然后它将不再调用touchesend。有什么想法吗?这是使用U

我如何检测长按视图的润色事件?例如,当用户按视图超过5秒,然后用手指触摸时

ui长按手势识别器
可用于固定时间的按键

我尝试使用:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
但当按下超过2秒时,将调用此函数:

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event

然后它将不再调用
touchesend
。有什么想法吗?

这是使用
UILongPressGestureRecognitor
的理想情况。这个类是专门为您的情况设计的,可以按如下方式实现

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
                       initWithTarget:self action:@selector(longPressOccured:)];
longPress.minimumPressDuration = 5;
[self.window addGestureRecognizer:longPress];

不清楚你想做什么。你想检测2秒钟的按压吗?为什么不能使用
UILongPressGestureRecognizer
?是否尝试使用UILongPressGestureRecognizer并设置属性minimumPressDuration?不要将手势识别器与
触摸组合使用…
方法!但当它按10秒时,我无法获得润色活动。