Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.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 sdk中的UILongPress手势_Iphone - Fatal编程技术网

iphone sdk中的UILongPress手势

iphone sdk中的UILongPress手势,iphone,Iphone,我有上面的代码去激活我的应用程序中的autoscroll定时器。这是用于此的函数 UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressOnUndoGesture:)]; [longPressOnUndoGesture setMini

我有上面的代码去激活我的应用程序中的autoscroll定时器。这是用于此的函数

 UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] 
    initWithTarget:self 
    action:@selector(handleLongPressOnUndoGesture:)];
    [longPressOnUndoGesture setMinimumPressDuration:2.0];
    [longPressOnUndoGesture release];
但当我按住2秒钟时,计时器不会停止。我的手势代码中是否有错误。
提前感谢。

您没有使用手势识别器,因为您在创建手势识别器时会立即将其释放。必须将其附着到如下视图:

-(void) handleLongPressOnUndoGesture:(UILongPressGestureRecognizer*)recognizer {
    [autoscrollTimer invalidate];

}

您没有使用手势识别器,因为您在创建手势识别器时会立即将其释放。必须将其附着到如下视图:

-(void) handleLongPressOnUndoGesture:(UILongPressGestureRecognizer*)recognizer {
    [autoscrollTimer invalidate];

}

在我看来,您似乎没有将手势识别器添加到它应该处理的视图中:

UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] 
initWithTarget:self 
action:@selector(handleLongPressOnUndoGesture:)];
[longPressOnUndoGesture setMinimumPressDuration:2.0];

// TRICK HERE
[self.view addGestureRecognizer:longPressUndoGesture];

[longPressOnUndoGesture release];

(如果
self
是您的控制器)。

在我看来,您没有将手势识别器添加到它应该使用的视图中:

UILongPressGestureRecognizer *longPressOnUndoGesture = [[UILongPressGestureRecognizer alloc] 
initWithTarget:self 
action:@selector(handleLongPressOnUndoGesture:)];
[longPressOnUndoGesture setMinimumPressDuration:2.0];

// TRICK HERE
[self.view addGestureRecognizer:longPressUndoGesture];

[longPressOnUndoGesture release];
(如果
self
是您的控制器)