touch事件與點選事件的衝突
阿新 • • 發佈:2019-02-08
做目前這個專案的時候,在自定義tableView裡重寫了touchesBegan、touchesMoved、touchesEnded幾種方法,後來發現這樣點選cell的時候,沒有任何響應,搜尋了很多都沒法解決,後來才白痴的發現,因為在重寫touch方法的時候,沒有呼叫其super方法,導致響應鏈斷裂了。。。所以才點選cell無效。
後來改成如下就好了:
-(void)touchesBegan:(NSSet<UITouch*> *)touches withEvent:(UIEvent *)event{
[supertouchesBegan:toucheswithEvent :event];
/**
........
*/
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
[supertouchesMoved:toucheswithEvent:event];
/**
........
*/
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
[supertouchesEnded:toucheswithEvent:event];
/**
........
*/
}