这是panGesture的实例。
pangstr = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
- (void)handlePan:(UIPanGestureRecognizer *)recognizer{
CGPoint translation = [recognizer translationInView:baseView];
recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y);
[recognizer setTranslation:CGPointMake(0, 0) inView:baseView];
if (recognizer.state == UIGestureRecognizerStateEnded) {
CGPoint velocity = [recognizer velocityInView:baseView];
CGFloat magnitude = sqrtf((velocity.x * velocity.x));
CGFloat slideMult = magnitude / 1000;
NSLog(@"magnitude: %f, slideMult: %f", magnitude, slideMult);
float slideFactor = 0.15 * slideMult;
CGPoint finalPoint = CGPointMake(recognizer.view.center.x + (velocity.x * slideFactor),
recognizer.view.center.y + (velocity.y * slideFactor));
}
现在我的问题是我如何使用(panGestureRecogniser *)识别器参数 - (void)touchesMoved:(NSSet *)触及withEvent:(UIEvent *)事件函数。 我特别想要这个,因为我想在我的TouchesMoved函数中获取finalPoint的值,而CGPoint finalPoint使用* recogniser参数。
如果有人能给我一个解决方案,真的很棒 感谢
答案 0 :(得分:0)
为什么不使用识别器状态?
if (recognizer.state == UIGestureRecognizerStateChanged)
{
//Save whatever information you need here
}
对于共享变量,请为StateChanged
使用不同的变量并在StateEnded
中同步它们?