UITapGestureRecognizer 和 CCMenu點選問題

OpenSoucre發表於2013-07-02

當一個scene中同時有UITapGestureRecognizer和CCMenu,點選時不會響應CCMenu,此時必須對UITapGestureRecognizer進行設定

    UITapGestureRecognizer *tapGestureRecognizer =[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTapGestureRecognizer:)];
        tapGestureRecognizer.cancelsTouchesInView = NO;
        [self addGestureRecognizer:tapGestureRecognizer];

cancelsTouchesInView為YES,表示當Gesture Recognizers識別到手勢後,會向hit-test view傳送 touchesCancelled:withEvent:訊息來取消hit-test view對此觸控序列的處理,這樣只有Gesture Recognizers能響應此觸控序列,hit-test view不再響應。如果為NO,則不傳送touchesCancelled:withEvent:訊息給hit-test view,這樣會使Gesture Recognizers和hit-test view同時響應觸控序列。

相關文章