• 双击手势屏蔽单击手势


     1 #pragma  mark - 添加Tab手势
     2 -(void)createTabGR{
     3 
     4     //创建一个Tab点击手势
     5     //发生点击后调用本类的tap方法,把tgr传入
     6     UITapGestureRecognizer * tgr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)];
     7     //默认敲击次数为 1
     8     //所有的UIview的子类视图都可以添加手势
     9     //把手势添加到图片视图上
    10     [_imageView addGestureRecognizer:tgr];
    11     
    12     //添加双击手势
    13     UITapGestureRecognizer * doubletgr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(doubleTap:)];
    14     //设置敲击次数为2
    15     doubletgr.numberOfTapsRequired = 2;
    16     
    17     [_imageView addGestureRecognizer:doubletgr];
    18     
    19     //设置满足双击的情况下不触发单机
    20     [tgr requireGestureRecognizerToFail:doubletgr];
    21 
    22 }
    23 
    24 //单次手势事件
    25 -(void)tap:(UITapGestureRecognizer *)tgr{
    26     //手势所在的视图
    27     //UIView * view = tgr.view;
    28     NSLog(@"图片被单击了...");
    29 }
    30 
    31 //双击手势事件
    32 -(void)doubleTap:(UITapGestureRecognizer *)doubletgr{
    33     NSLog(@"图片被双击了...");
    34 }
  • 相关阅读:
    20210718力扣第249场周赛(五)
    统计学习方法第三章 k近邻法
    统计学习方法第二章
    启发式搜索
    洛谷P2015 二叉苹果树
    Codeforces Round #736 (Div. 2). D
    牛客多校第五场 K King of Range
    RMQ/ST表
    AcWing100 IncDec Sequence
    AcWing 368. 银河
  • 原文地址:https://www.cnblogs.com/W-Kr/p/5208873.html
Copyright © 2020-2023  润新知