4

I am working on Xamarin.iOS. I need that when I long press on a UITableCell of a UITableView a specific menu pop up in the form of UIActionSheet.

I have tried using the sources at Xamarin official website but I failed. Have anyone done this before?

Iain Smith
  • 9,230
  • 4
  • 50
  • 61
theMAMs
  • 83
  • 2
  • 13

1 Answers1

4

In this sample I managed to add a long press gesture by altering this method in GrowRowTableCell

public GrowRowTableCell (IntPtr handle) : base (handle)
{
    var longPressGesture = new UILongPressGestureRecognizer (LongPressMethod);
    AddGestureRecognizer (longPressGesture);
}


void LongPressMethod (UILongPressGestureRecognizer gestureRecognizer)
{
    if(gestureRecognizer.State == UIGestureRecognizerState.Began)
    {
        Console.Write("LongPress");
        var selectCategory = new UIActionSheet ("ActionSheet", null, "Cancel", "test");
        selectCategory.ShowInView (this);
    }
}

looks like this:

enter image description here

Iain Smith
  • 9,230
  • 4
  • 50
  • 61