如何在Xamarin中使用UISwipeGestureRecognizer?

时间:2018-01-08 17:46:24

标签: ios xamarin xamarin.ios

如何在Xamarin中使用UISwipeGestureRecognizer?这是我到目前为止的代码,它没有用,当我滑动没有任何事情发生。

    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        // Perform any additional setup after loading the view, typically from a nib.
        ImageView.Image = new UIImage((string)ListOfImages[0]);

        var swipeRight = new UISwipeGestureRecognizer(this, new ObjCRuntime.Selector("swiped:"));
        swipeRight.Direction = UISwipeGestureRecognizerDirection.Right;
        ImageView.AddGestureRecognizer(swipeRight);
    }
    public void swiped(UIGestureRecognizer gesture)
    {
        Console.WriteLine("User swiped right");
    }

2 个答案:

答案 0 :(得分:0)

您需要使用与您使用的选择器相同的名称导出方法:

function DMC_n(){
   DMC('Elements', [1,2]);  
}

function DMC(shtName, arr){
  var sheet =  SpreadsheetApp.getActiveSpreadsheet().getSheetByName(shtName);
  var range = sheet.getDataRange();
  var values = range.getValues();

  for (var i = 0; i <= arr.length -1; i++){
      sheet.deleteColumns(arr[i]);
      };
}

或者使用接受C#[Export("swiped:")] public void swiped(UIGestureRecognizer gesture) { Console.WriteLine("User swiped right"); }

的重载
Action

答案 1 :(得分:0)

var swipeRight = new UISwipeGestureRecognizer(swiped);