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

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];

longPress.delegate = self;

[self.view addGestureRecognizer:longPress];

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

- (void)longPress:(UILongPressGestureRecognizer *)sender {

    if (sender.state == UIGestureRecognizerStateBegan) {

         [self yourMethod];

    }

}

最新文章

  1. 30. PL/SQL Developer连接服务器查询时,数据乱码处理
  2. threeSum_0
  3. hdu 3549 Flow Problem
  4. Scala学习——数组/映射/元组
  5. UVA 10537 The Toll! Revisited 过路费(最短路,经典变形)
  6. Bootstrap_Javascript_滚动监视器
  7. 为应用程序的选项卡及ActionBar设置样式
  8. I can do it
  9. [Swift]LeetCode919. 完全二叉树插入器 | Complete Binary Tree Inserter
  10. iframe父页面与子页面赋值
  11. js 小写金额转大写
  12. PyCharm 如何新建Django工程项目
  13. falsk简单项目示例
  14. 使用Swagger2时遇到的问题
  15. Codeforces-gym-101020 problem C. Rectangles
  16. idhttp与cookie
  17. 定制FileField中的上传文件名称
  18. (转)Spring Cloud(二)
  19. centos7 虚拟机安装docker-ce-17.09
  20. 不用中间变量交换a 和b的值

热门文章

  1. jqGrid简单介绍
  2. eclipse报错 com/genuitec/eclipse/j2eedt/core/J2EEProjectUtil 转
  3. VS 2010不显示头文件源文件和所有以前分类的文件夹,*.h 和*.cpp都显示在同一个文件
  4. java基础(五)
  5. iOS设备保持横排方向
  6. 《Linear Algebra and Its Applications》-chaper6-正交性和最小二乘法-基本概念与定理
  7. zoj 3757 Alice and Bob and Cue Sports 月赛A 模拟
  8. Nginx系列~负载均衡服务器与WWW服务器的实现
  9. 一款很不错的html转xml工具-Html Agility Pack
  10. zoj 3657 策略题 easy