ios - Locking UIPanGestureRecognizer to a certain direction -
i have uipangesturerecognizer
, i'm trying swipe in 1 direction (up). haven't been able find solution works. thanks. current code:
- (void)pangesture:(uipangesturerecognizer *)recognizer{ cgpoint t = [recognizer translationinview:self.view]; recognizer.view.center = cgpointmake(recognizer.view.center.x + t.x, recognizer.view.center.y + t.y); [recognizer settranslation:cgpointmake(0, 0) inview:self.view]; }
- (void)pangesture:(uipangesturerecognizer *)recognizer { cgpoint t = [recognizer translationinview:self.view]; if (t.y < 0) { t = cgpointmake(0, t.y); } else { t = cgpointmake(0, 0); // @ } recognizer.view.center = cgpointmake(recognizer.view.center.x + t.x, recognizer.view.center.y + t.y); [recognizer settranslation:cgpointmake(0, 0) inview:self.view]; }
to able drag , down use cgpointmake(0, t.y);
instead of if
Comments
Post a Comment