Created
May 11, 2011 00:21
-
-
Save anujb/965668 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Recognizer<T> : NSObject where T : UIGestureRecognizer, new() | |
{ | |
T fRecognizer; | |
public T Instance { | |
get { return fRecognizer; } | |
} | |
Selector fSelector = new Selector("MyKit.Selector"); | |
public Recognizer() | |
{ | |
fRecognizer = new T(); | |
fRecognizer.AddTarget(this, fSelector); | |
fRecognizer.Delegate = new RecognizerDelegate(); | |
} | |
public event Action<T> OnRecognized; | |
[Export("MyKit.Selector")] | |
public void Recognized(UIGestureRecognizer recognizer) | |
{ | |
if(OnRecognized != null) | |
OnRecognized(fRecognizer as T); | |
} | |
static bool isfalse = false; | |
static void Foo() | |
{ | |
if(isfalse) | |
{ | |
var foo1 = new UITapGestureRecognizer(); | |
var foo2 = new UISwipeGestureRecognizer(); | |
var foo3 = new UILongPressGestureRecognizer(); | |
} | |
} | |
} | |
public class RecognizerDelegate : UIGestureRecognizerDelegate | |
{ | |
public override bool ShouldReceiveTouch(UIGestureRecognizer recognizer, UITouch touch) | |
{ | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment