比如當前的collectionViewA(藍色), 還有一個collectionViewCellA(紅色),collectionViewCellA(紅色)里面有一個collectionViewB(綠色),
collectionViewCellB(綠色)里面有兩個collectionViewCellB1(白色)、collectionViewCellB2(白色)
點擊collectionViewCellA(紅色) 彈出點擊collectViewAcell
點擊collectionViewB(綠色) 也彈出點擊collectViewAcell
點擊collectionViewCellB1(白色)、collectionViewCellB2(白色) 彈出點擊collectViewBcell
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event { CGPoint btnPointInA = [self.collectView convertPoint:point fromView:self]; if ([self.collectView pointInside:btnPointInA withEvent:event]) { for (UIView *subView in self.collectView.subviews) { CGPoint subViewPoint = [subView convertPoint:point fromView:self]; if ([subView pointInside:subViewPoint withEvent:event]) { return subView; } return self; } // 否則,返回默認處理 return [super hitTest:point withEvent:event]; }