UICollectionView delegate's tap method not getting called

后端 未结 8 1648
梦毁少年i
梦毁少年i 2021-01-03 20:50

I have a collection view, the datasource delegate works well, but UICollectionViewDelegate:

-(void)collectionView:(UICollectionView *)collection         


        
8条回答
  •  我在风中等你
    2021-01-03 21:21

    Adding here as a reference for other people who are looking for the answer

    Short Answer:

    Delay the touches of default gesture recognizers associated with the tableview:

        if let gestures = tableView.gestureRecognizers{
            for gesture in gestures {
                gesture.delaysTouchesBegan = true
            }
        }
    

    Explanation

    Every tableview has gesture recognizers associated with it. Which causes the delays of touches to custom UItableView cell. Set the delaysTouchesBegan to true so that the touch can be passed to subviews quickly.

    In my case it was CollectionViewController inside UItableViewCell for which collectionView:didSelectItemAtIndexPath was being called with a delay.

提交回复
热议问题