ios Touch事件

记录直供自己备忘使用,勿喷。


/**
 * 说明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]];
            }
        }
    }
}

阅读更多
版权声明:好记星不如烂笔头,欢迎批判转载 https://blog.csdn.net/ab601026460/article/details/49933133
个人分类: iOS
上一篇IOS-简单UI组件的一些常见问题
下一篇xcode权限
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭