- (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