您的位置:首页 > 移动开发 > IOS开发

ios Touch事件

2015-11-19 20:16 330 查看
记录直供自己备忘使用,勿喷。



/**
* 说明touchesBegan 太灵敏了,换成touchesEnded
* 判断当前的手指点击的地方是否在一个点击区域内,进行事件处理
*/
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
DLog(@"touchesBegan-------------");
UITouch *touch =  [touches anyObject];
CGPoint currentLocation = [touch locationInView:self];
NSInteger tapCount = touch.tapCount;
if (tapCount >= 2) {
DLog(@"touchesBegan-------------typcount:%i", tapCount);
}

for (int i = 0; i <  [_rectArr count]; ++i) {
NSValue *value = [_rectArr objectAtIndex:i];
CGRect cgRect = [value CGRectValue];
if (CGRectContainsPoint(cgRect, currentLocation)) {
//[SVProgressHUD showErrorWithStatus:[NSString stringWithFormat:@"点击了%d行",i]];
if (self.delegate && [self.delegate respondsToSelector:@selector(landscapeBarNoXYView: didSelectLineBar:)]) {
[self.delegate landscapeBarNoXYView:self didSelectLineBar:[NSString stringWithFormat:@"%i", i]];
}
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: