UILongPressGestureRecognizer 运行两次的解决的方法

            近期维护之前用iOS SDK 3.2写过的3年多前的map方面的模块,在地图上长按pin,发觉一个点莫名奇异点插了两个pin。

查了一下,原来是如今的sdk要在UILongPressGestureRecognizer绑定的selector方法里对UILongPressGestureRecognizer.state 进行下推断,额。蛋疼。下附问题解决的方法:

//长按地图事件
- (void)longPressGestureRecognizerAction:(UILongPressGestureRecognizer* )gestureRecognizer
{
    if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
        NSLog(@"Long press Ended");
    }
    else {
        NSLog(@"Long press detected.");
        //OOXX.....
    }
}

參考:

http://www.cocoachina.com/ask/questions/show/108149

http://blog.csdn.net/yu0089/article/details/8244851


posted @ 2017-07-09 11:21  wzzkaifa  阅读(356)  评论(0编辑  收藏  举报