首页 > 其他 > 详细

UILongPressGestureRecognizer两次触发

时间:2014-03-05 18:39:57      阅读:403      评论:0      收藏:0      [点我收藏+]

当你使用longPress gesture recognizer 时,你可能会发现调用了多次。

 

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPress:)];

    longPress.delegate = self;

    [self.viewaddGestureRecognizer:longPress];

其实时因为响应不同的状态。所以,要在你的方法里加上状态的判断。可以看到,开始响应,结束响应,如果你不判断的话,都会调用你的方法。

-(void)longPress:(UILongPressGestureRecognizer *)sender

{

    if (sender.state == UIGestureRecognizerStateBegan) {

        [self yourMethod];

    }

}

 

UIPichGestureRecognizer捏合手势、UIRotationGestureRecognizer旋转手势等也会两次触发。

UILongPressGestureRecognizer两次触发,布布扣,bubuko.com

UILongPressGestureRecognizer两次触发

原文:http://www.cnblogs.com/nomine/p/3581982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!