UILongPressGestureRecognizer 执行两次的解决办法

来源:互联网 发布:淘宝运营服务商可信度 编辑:程序博客网 时间:2024/05/17 01:47

            最近维护之前用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


0 0