详解iOS cancelsTouchesInView delaysTouchesBegan delaysTouchesEnded


- (void)viewDidLoad {

    [super viewDidLoad];

 

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];

                                 /*

                                  2017-03-03 11:57:35.266 ResponseChain[53875:3956994] =========> base view touchs Began

                                  2017-03-03 11:57:35.391 ResponseChain[53875:3956994] =========> single Tapped

                                  2017-03-03 11:57:35.392 ResponseChain[53875:3956994] =========> base view touchs Cancelled

                                  

                                  2017-03-03 11:57:40.240 ResponseChain[53875:3956994] =========> click testbtn

                                  

                                  2017-03-03 11:57:41.784 ResponseChain[53875:3956994] =========> base view touchs Began

                                  2017-03-03 11:57:41.920 ResponseChain[53875:3956994] =========> single Tapped

                                  2017-03-03 11:57:41.920 ResponseChain[53875:3956994] =========> base view touchs Cancelled

                                  */

    //tap.cancelsTouchesInView = NO;

                                 /*

                                  2017-03-03 11:54:04.806 ResponseChain[53805:3954398] =========> base view touchs Began

                                  2017-03-03 11:54:04.909 ResponseChain[53805:3954398] =========> single Tapped

                                  2017-03-03 11:54:04.910 ResponseChain[53805:3954398] =========> base view touchs Ended

                                  2017-03-03 11:54:07.400 ResponseChain[53805:3954398] =========> single Tapped

                                  

                                  2017-03-03 11:54:07.401 ResponseChain[53805:3954398] =========> click testbtn

                                  

                                  2017-03-03 11:54:10.654 ResponseChain[53805:3954398] =========> base view touchs Began

                                  2017-03-03 11:54:10.725 ResponseChain[53805:3954398] =========> single Tapped

                                  2017-03-03 11:54:10.726 ResponseChain[53805:3954398] =========> base view touchs Ended

                                  */

    tap.delaysTouchesBegan = YES;

                                 /*tap.delaysTouchesBegan = YES || tap.cancelsTouchesInView = NO 输出结果

                                  2017-03-03 11:50:57.172 ResponseChain[53740:3952166] =========> single Tapped

                                  2017-03-03 11:51:03.564 ResponseChain[53740:3952166] =========> single Tapped

                                  2017-03-03 11:51:05.636 ResponseChain[53740:3952166] =========> single Tapped

                                  

                                  //tap.delaysTouchesBegan = YES 输出结果

                                  2017-03-03 11:51:56.599 ResponseChain[53775:3953294] =========> single Tapped

                                  2017-03-03 11:51:58.296 ResponseChain[53775:3953294] =========> click testbtn

                                  2017-03-03 11:51:59.655 ResponseChain[53775:3953294] =========> single Tapped

                                  */

    tap.delaysTouchesEnded = YES;

                                   /*

                                   2017-03-03 11:47:59.749 ResponseChain[53704:3950843] =========> base view touchs Began

                                   2017-03-03 11:47:59.891 ResponseChain[53704:3950843] =========> single Tapped

                                   2017-03-03 11:47:59.892 ResponseChain[53704:3950843] =========> base view touchs Ended

                                    

                                   2017-03-03 11:48:06.323 ResponseChain[53704:3950843] =========> single Tapped

                                   2017-03-03 11:48:06.324 ResponseChain[53704:3950843] =========> click testbtn

                                    

                                   2017-03-03 11:48:22.708 ResponseChain[53704:3950843] =========> base view touchs Began

                                   2017-03-03 11:48:22.789 ResponseChain[53704:3950843] =========> single Tapped

                                   2017-03-03 11:48:22.789 ResponseChain[53704:3950843] =========> base view touchs Ended

                                   */

    [self.view addGestureRecognizer:tap];

    

    [_testBtn addTarget:self action:@selector(testBtnClicked) forControlEvents:UIControlEventTouchUpInside];

}


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

        NSLog(@"=========> base view touchs Began");

    }

- (void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

        NSLog(@"=========> base view touchs Moved");

    }

- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

        NSLog(@"=========> base view touchs Ended");

}

- (void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {

        NSLog(@"=========> base view touchs Cancelled");

    }

- (void)tapAction {

        NSLog(@"=========> single Tapped");

}

- (void)testBtnClicked {

    NSLog(@"=========> click testbtn");

}




详细内容:http://www.jianshu.com/p/cb0314b72883  

demo 下载地址:https://github.com/sunjie19921111/ResponseChain


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值