如何在xamarin.ios上的表格单元格上启用长按手势?

时间:2016-05-03 16:38:48

标签: xamarin xamarin.ios uilongpressgesturerecogni

我正在研究Xamarin.iOS。当我长按UITableCell UITableView某个特定菜单UIActionSheet时,我需要这样做。

我曾尝试在Xamarin官方网站上使用这些来源,但我失败了。 有人这么做过吗?

1 个答案:

答案 0 :(得分:3)

在此sample中,我设法通过在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);
    }
}

看起来像这样:

enter image description here