I have a UICollectionView
(A) with photo gallery thumbnails inside a UICollectionViewCell
of another UICollectionView
(B).
I'd like to achieve this behavior:
UICollectionView
(A) I'd like to open (B) cell detail. But the empty area of the UICollectionView
(A) cancels user touches and doesn't forward them to the (B) cell. I have:
_collectionView.canCancelContentTouches = NO;
_collectionView.delaysContentTouches = NO;
and using autolayout.
Thank you for your help!
I found a solution. I subclassed UICollectionView and then override hitTest method.
- (UIView *) hitTest:(CGPoint)point withEvent:(UIEvent *)event {
UIView* view = [super hitTest:point withEvent:event];
if (view == self) {
return self.superview;
}
else {
return view;
}
}
swift version
override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
let v = super.hitTest(point, withEvent: event)
return v == self ? superview : v
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.