1
我一直試圖在MKAnnotationView
子類中使用UILongPressGestureRecognizer
。有趣的是,手勢識別器僅在使用兩個手指/觸摸時觸發。MKAnnotationView上的UILongPressGestureRecognizer不起作用於單點觸摸
什麼可以防止手勢識別器只觸發一次觸發?
實施
UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self
action:@selector(handleLongPress:)];
pressRecognizer.minimumPressDuration = 0.25;
pressRecognizer.numberOfTapsRequired = 0;
pressRecognizer.numberOfTouchesRequired = 1;
在正常UIView
相同的實現顯示了預期的行爲,一點觸式工作。然而,可以使用touchesBegan:
和touchesEnded:
來獲得長按手勢,我仍然很好奇這是什麼原因。