touchesBegan ไม่ได้ถูกเรียกบนคลาสย่อย UICollectionView

ฉันได้จัดคลาสย่อย UICollectionView เป็น CoolGridCollectionView และฉันได้แทนที่เมธอด touchesBegan: และ touchesEnded: แล้ว แต่สิ่งเหล่านั้นจะไม่ถูกเรียกเมื่อฉันแตะเซลล์ และเซลล์นั้นก็มีตัวจดจำท่าทางด้วยการแตะครั้งเดียวและสองครั้ง ฉันต้องการตำแหน่งที่ก๊อกน้ำเกิดขึ้น ฉันสามารถรับตำแหน่งได้โดยใช้ covertPoint: อย่างอื่น แต่เหตุใดจึงไม่เรียกวิธีการสัมผัส? iOS รองรับการสัมผัส UICollectionView โดยเฉพาะหรือไม่


person Shanmugaraja G    schedule 04.07.2016    source แหล่งที่มา
comment
เพิ่ม Gesture ใน windows คุณจะได้รับ Touch   -  person Ujesh    schedule 04.07.2016


คำตอบ (1)


ฉันไม่แน่ใจ 100% แต่คุณสามารถลองใช้วิธี hitTest:withEvent: แทน -touchesBegan:withEvent: method หวังว่านี่จะเป็นประโยชน์กับคุณ

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
    touchedView = [super hitTest:point withEvent:event];
    NSSet* touches = [event allTouches];
    // handle touches if you need
    return touchedView;
}
person TestGrid.io Team    schedule 07.07.2016