我之前从未使用过手势,并编写了这段代码(注意:我使用的是Xamarin和iOS)。
当我使用下面的代码时,尽管我在模拟器或我的实际iPhone上做了什么,但我收到的唯一值是“正确”。我很难过为什么。我想我应该什么也得不到,或者一切都应该有用。
// Swipe gesture
this.View.AddGestureRecognizer(new UISwipeGestureRecognizer(sw =>
{
if (sw.Direction == UISwipeGestureRecognizerDirection.Left) {
txtTestLabel.Text = "Left";
}
else if (sw.Direction == UISwipeGestureRecognizerDirection.Right) {
txtTestLabel.Text = "Right";
}
else {
txtTestLabel.Text = sw.Direction.ToString();
}
}));