swift - Find out the view of the gesture has been set -


in secondviewcontroller have uitableview custom uitableviewcell have uipangesturerecognizer , want fail when othergesturerecognizer uipangesturerecognizer viewcontroller firstviewcontroller

the uipangesturerecognizer of the cell set self , tried using gesturerecognizer: shouldrequirefailureofgesturerecognizer:

override func gesturerecognizer(gesturerecognizer: uigesturerecognizer, shouldrequirefailureofgesturerecognizer othergesturerecognizer: uigesturerecognizer) -> bool {     let view = othergesturerecognizer.view     if let view as? firstviewcontroller.view { // doesn't work         return true     }     return false } 

the question is, how can fail uipangesturerecognizer of uitableviewcell when gesture has been recognized firstviewcontroller?

this may seem silly, seems me problem purely 1 of identification: gesture recognizer, othergesturerecognizer, particular gesture recognizer i'm worried , supposed yield to? occurs me 2 choices:

  • you have, rightly point out, view. there no questions can ask view identify it? has distinguishing backgroundcolor or other feature here? class? plain vanilla uiview, or of distinguishing class?

  • you have uipangesturerecognizer itself. drop-dead simple solution, i'd use, subclass uipangesturerecognizer: let's call subclass myspecialpangesturerecognizer. subclass has no special functionality, , no purpose except act identifier! when give view gesture recognizer, make gesture recognizer myspecialpangesturerecognizer. can ask whether othergesturerecognizer myspecialpangesturerecognizer.


Popular posts from this blog