在UIScrollView中检测长按

Egi*_*son 4 iphone cocoa-touch iphone-sdk-3.0

如何在UIScrollView中检测到长按(点击并按住)?

Vla*_*mir 9

在视图中,touchesBegan:您可以延迟调用"长按"手柄.

[touchHandler performSelector:@selector(longTap:) withObject:nil afterDelay:1.5];
Run Code Online (Sandbox Code Playgroud)

然后在视图中touchesEnded:,如果时间不够,您可以取消该呼叫:

[NSObject cancelPreviousPerformRequestsWithTarget:touchHandler selector:@selector(longTap:) object:nil];
Run Code Online (Sandbox Code Playgroud)