当 superview 有 tapGesture 时,collectionView 没有调用 didSelectItemAtIndexPath?这是为什么?
为什么它根据响应者链打印“doGesture”?
不调用 didSelectItemAtIndexPath。
- (void)viewDidLoad {
[super viewDidLoad];
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
self.collectionView = [[MyCollectionView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height - 100) collectionViewLayout:flowLayout];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"abc"];
self.collectionView.delegate = self;
self.collectionView.dataSource = self;
[self.view addSubview:self.collectionView];
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(doGesture)];
tapGesture.delegate = self;
[self.view addGestureRecognizer:tapGesture];
}
- (void)doGesture
{
NSLog(@"%@",@"doGesture");
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return 100; …Run Code Online (Sandbox Code Playgroud)