UIKit

iOS - 不能触发didSelectRowAtIndexPat

2016-08-23  本文已影响1886人  Mr_Bob_
前言:

最近在项目中遇到didSelectRowAtIndexPath方法不能响应的情况,具体提操作如下:

Untitled.gif
会出现点击 Cell 不起作用的,下面总结了几种didSelectRowAtIndexPath方法不能正常响应的情况:

主要讲一下最后一种情况:

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tappedCancel)];
    [bg addGestureRecognizer:tapGesture];
    tapGesture.delegate = self;
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
        return NO;
    }
    return  YES;
}
上一篇下一篇

猜你喜欢

热点阅读