Sha256: 2c7d1e93e6e93310776605c3041e2445c97f6ba2276d2a43168f7eb2d67abb06
Contents?: true
Size: 1.14 KB
Versions: 5
Compression:
Stored size: 1.14 KB
Contents
# Opens UIView to add methods for working with gesture recognizers. class UIView def whenTapped(&proc) addGestureRecognizerHelper(proc, UITapGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end def whenPinched(&proc) addGestureRecognizerHelper(proc, UIPinchGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end def whenRotated(&proc) addGestureRecognizerHelper(proc, UIRotationGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end def whenSwiped(&proc) addGestureRecognizerHelper(proc, UISwipeGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end def whenPanned(&proc) addGestureRecognizerHelper(proc, UIPanGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end def whenPressed(&proc) addGestureRecognizerHelper(proc, UILongPressGestureRecognizer.alloc.initWithTarget(proc, action:'call')) end private # Adds the recognizer and keeps a strong reference to the Proc object. def addGestureRecognizerHelper(proc, recognizer) self.addGestureRecognizer(recognizer) @recognizers = {} unless @recognizers @recognizers["#{proc}"] = proc end end
Version data entries
5 entries across 5 versions & 1 rubygems