if (gesture.state == UIGestureRecognizerStateBegan) {
_initial = [gesture locationInView:self.view];
}else if (gesture.state == UIGestureRecognizerStateChanged){
CGPoint p = [gesture locationInView:self.view];
double dy = p.y - _initial.y;
if (dy > 0) {
NSLog(@"Finger moved to the up");
}
else {
NSLog(@"Finger moved to the down");
}
}
這是我的方法來檢測UILongPressGestureRecognizer方向,但我想 檢測方向不是比較初始點,但比較stateChanged點。檢測UILongPressGestureRecognizer方向不能比擬的初始點
這很難描述,例如:表格0至7已啓動,但7至-5降低,然後-5至-2升高。
UILongPressGestureRecognizer沒有translationInView方法 –
您的文章說, 「UIPanGestureRecognizer」。現在你說longpress。也沒有這種東西longpressrecognizer,也可以檢測平移。他們都是兩個不同的東西。 – GeneCode