這里就要說(shuō)到 iOS 的響應(yīng)鏈iOS 的所有點(diǎn)擊方法 都是用響應(yīng)鏈 傳遞到最底層的 所以可以截取響應(yīng)鏈 讓colllectionView失效
用在tablviewCell里面即可
//OC 寫(xiě)法
-?(UIView?*)hitTest:(CGPoint)point?withEvent:(UIEvent?*)event{??
UIView?*view?=?[super?hitTest:point?withEvent:event];??
if?([view?isKindOfClass:[UICollectionView?class]])?{??
return?self;??
????}??
return?[super?hitTest:point?withEvent:event];??
}?
//swift4.0 寫(xiě)法
// 修改 tablview 和collection 嵌套 導(dǎo)致tablview cell點(diǎn)擊不到
? ? override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
? ? ? let view = super.hitTest(point, with: event)
? ? ? ? if let touchView = view {
? ? ? ? ? ? if touchView.isKind(of: UICollectionView.self ){
? ? ? ? ? ? ? ? return self
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? return super.hitTest(point, with: event)
? ? }