Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.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
Iphone 我怎样才能感觉到用户在屏幕上按住手指而不移动?_Iphone_Cocoa_Cocoa Touch_Ipad - Fatal编程技术网

Iphone 我怎样才能感觉到用户在屏幕上按住手指而不移动?

Iphone 我怎样才能感觉到用户在屏幕上按住手指而不移动?,iphone,cocoa,cocoa-touch,ipad,Iphone,Cocoa,Cocoa Touch,Ipad,我能想到的最好的方法是在touchesbeeted事件方法中启动计时器。如果计时器在touchesEnded事件到达之前过期,则您知道用户正在按住屏幕。如果调用touchesMoved事件,则只需重置计时器,以便仅检测按住而不移动 iOS SDK中是否内置了任何功能来准确处理此问题?或者任何人都能想到的更好、更简单、更快的方法 提前感谢您的帮助 我不知道还有什么方法可以测试无运动;我想你是怎么做的就足够简单了 您很可能无法使用touchesMoved重置计时器,因为计时器非常、非常敏感,而且您移

我能想到的最好的方法是在touchesbeeted事件方法中启动计时器。如果计时器在touchesEnded事件到达之前过期,则您知道用户正在按住屏幕。如果调用touchesMoved事件,则只需重置计时器,以便仅检测按住而不移动

iOS SDK中是否内置了任何功能来准确处理此问题?或者任何人都能想到的更好、更简单、更快的方法


提前感谢您的帮助

我不知道还有什么方法可以测试无运动;我想你是怎么做的就足够简单了

您很可能无法使用
touchesMoved
重置计时器,因为计时器非常、非常敏感,而且您移动手指时甚至无法用肉眼看到它(请随时使用NSLogs对此进行测试,以了解我的意思)

在重置计时器之前,您可能需要为触摸移动的
值与原始值的变化量设置某种类型的阈值差值。

尝试使用

当用户长按
[targetsomeaction:gr]
时,将调用它

UILongPressGestureRecognizer* gr = [[UILongPressGestureRecognizer alloc]
                                    initWithTarget:theTarget
                                            action:@selector(someAction:)];
// change options of gr if you like.
// default: tolerate movement up to 4 px, fire the event after 0.4 secs.
[theView addGestureRecognizer:gr];
[gr release];