Ios 长新闻视图事件
我如何检测长按视图的润色事件?例如,当用户按视图超过5秒,然后用手指触摸时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
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秒时,我无法获得润色活动。