Created
July 27, 2013 09:53
-
-
Save amay077/6094422 to your computer and use it in GitHub Desktop.
Using UIGestureRecognizer in Xamarin.iOS
ref: http://qiita.com/amay077/items/a6754176f2abe339adce
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
using System; | |
using System.Drawing; | |
using MonoTouch.Foundation; | |
using MonoTouch.UIKit; | |
using System.Diagnostics; | |
namespace GesturesSample | |
{ | |
public partial class GesturesSampleViewController : UIViewController | |
{ | |
public GesturesSampleViewController() : base ("GesturesSampleViewController", null) | |
{ | |
} | |
public override void ViewDidLoad() | |
{ | |
base.ViewDidLoad(); | |
// Tap gesture | |
this.View.AddGestureRecognizer(new UITapGestureRecognizer(tap => | |
{ | |
Debug.WriteLine("Double Tap."); | |
}) | |
{ | |
NumberOfTapsRequired = 2 // Double tap | |
}); | |
// Drag(Pan) gesture | |
this.View.AddGestureRecognizer(new UIPanGestureRecognizer(pan => | |
{ | |
var p = pan.TranslationInView(this.View); | |
var v = pan.VelocityInView(this.View); | |
Debug.WriteLine("Pan. transration:{0}, velocity:{1}", p, v); | |
})); | |
// Pinch gesture | |
this.View.AddGestureRecognizer(new UIPinchGestureRecognizer(pin => | |
{ | |
var scale = pin.Scale; | |
var v = pin.Velocity; | |
Debug.WriteLine("Pinch. scale:{0}, velocity:{1}", scale, v); | |
})); | |
// Swipe gesture | |
this.View.AddGestureRecognizer(new UISwipeGestureRecognizer(sw => | |
{ | |
Debug.WriteLine("Swipe."); | |
})); | |
// Rotate gesture | |
this.View.AddGestureRecognizer(new UIRotationGestureRecognizer(ro => | |
{ | |
var rotation = ro.Rotation; | |
var v = ro.Velocity; | |
Debug.WriteLine("Rotate. rotation:{0}, velocity:{1}", rotation, v); | |
})); | |
// Long press gesture | |
this.View.AddGestureRecognizer(new UILongPressGestureRecognizer(lp => | |
{ | |
Debug.WriteLine("Long press."); | |
})); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment