OGeek|极客世界-中国程序员成长平台

标题: ios - 为什么只显示右手势? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 06:46
标题: ios - 为什么只显示右手势?

我以前从未使用过手势,并编写了这段代码(注意:我使用的是 Xamarin 和 iOS)。

当我使用下面的代码时,收到的唯一值是“Right”,尽管我在模拟器或实际 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();
      }
}));



Best Answer-推荐答案


UISwipeGestureRecognizer 的默认方向是右(见 documentation)。将 direction 属性设置为 left 以跟踪向左滑动。

关于ios - 为什么只显示右手势?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22053433/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4