- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesBegan");
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesMoved");
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesEnded");
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesCancelled");
}
- (IBAction)panGestureRecognizerDidUpdate:(UIPanGestureRecognizer *)sender {
NSLog(@"panGesture");
}
当然泛笔势识别器被配置为发送 panGestureRecognizerDidUpdate:
消息。
现在假设你碰认为,移动你的手指够泛手势必须承认,,然后抬起手指。这款应用程序的打印是什么?
如果笔势识别器有 cancelsTouchesInView
设置为 YES
,这款应用程序将这些消息记录:
touchesBegan
touchesMoved
touchesCancelled
panGesture
panGesture
(etc.)
你可能会得到多个 touchesMoved
之前取消。
所以,如果你设置 cancelsTouchesInView
到 YES
(默认值),在它从笔势识别器,发送的第一个消息,您就不会在那触摸会更触摸相关的任何消息,你将会得到之前,系统将取消触摸。
如果笔势识别器有 cancelsTouchesInView
设置为 NO
,这款应用程序将这些消息记录:
touchesBegan
touchesMoved
panGesture
touchesMoved
panGesture
touchesMoved
panGesture
(etc.)
panGesture
touchesEnded
所以,如果你设置 cancelsTouchesInView
到 NO
,系统将继续发送手势触摸,与笔势识别器消息交错的触摸相关消息。触摸将正常结束而不是被取消 (除非系统取消触摸一些其他原因,像被触摸过程中按下首页按钮)。
最新
最早
最热