iPhone Gestures Adding 2 at once

Posted by BahaiResearch.com on Stack Overflow See other posts from Stack Overflow or by BahaiResearch.com
Published on 2011-01-02T03:42:00Z Indexed on 2011/01/02 3:54 UTC
Read the original article Hit count: 167

Filed under:
|
|

Objective C answers are fine too.

Currently I am using this code to add 2 gestures (left / right) to my WebView. Works fine.

Can I combine this into less code though to indicate that both gestures go to the same action?

//LEFT
UISwipeGestureRecognizer sgr = new UISwipeGestureRecognizer ();
sgr.AddTarget (this, MainViewController.MySelector);
sgr.Direction = UISwipeGestureRecognizerDirection.Left;
sgr.Delegate = new SwipeRecognizerDelegate ();
this.View.AddGestureRecognizer (sgr);

//RIGHT
UISwipeGestureRecognizer sgrRight = new UISwipeGestureRecognizer ();
sgrRight.AddTarget (this, MainViewController.MySelector);
sgrRight.Direction = UISwipeGestureRecognizerDirection.Right;
sgrRight.Delegate = new SwipeRecognizerDelegate ();
this.View.AddGestureRecognizer (sgrRight);

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad