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