iOS如何使UICollectionView下方的UIButton接收触摸?
我有下一个结构iOS如何使UICollectionView下方的UIButton接收触摸?,ios,objective-c,iphone,uibutton,Ios,Objective C,Iphone,Uibutton,我有下一个结构 UView - - UIView2 with Button - CollectionView - which overlap UIView2 and has contentInset 我无法使按钮接收触摸事件 我尝试使用检查清除颜色的pointInside(collectionView的backgroundColor设置为清除颜色) 但我需要滚动蓝色部分上的工作事件(UIView2) 所以,我需要然后我触摸collectionView触摸也会收到一个U
UView -
- UIView2 with Button
- CollectionView - which overlap UIView2 and has contentInset
我无法使按钮接收触摸事件
我尝试使用检查清除颜色的pointInside(collectionView的backgroundColor设置为清除颜色)
但我需要滚动蓝色部分上的工作事件(UIView2)
所以,我需要然后我触摸collectionView触摸也会收到一个UIButton
可能吗?为什么集合视图需要重叠按钮?无论如何,您可以尝试在UIView中覆盖HitTest,如下所示:
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
CGPoint pointInUIView2 = [UIView2 convertPoint:point fromView:self];
if ([UIView2 pointInside:pointInUIView2 withEvent:event])
{
return UIView2;
}
else
{
return [super hitTest:point withEvent:event];
}
}