【问题标题】:How to enable long press gesture on table cell in xamarin.ios?如何在 xamarin.ios 中的表格单元格上启用长按手势?
【发布时间】:2016-05-03 16:38:47
【问题描述】:

我正在开发 Xamarin.iOS。当我长按UITableCellUITableView 时,我需要它以UIActionSheet 的形式弹出一个特定菜单。

我曾尝试使用 Xamarin 官方网站上的资源,但失败了。 以前有人做过吗?

【问题讨论】:

    标签: xamarin xamarin.ios uilongpressgesturerecogni


    【解决方案1】:

    在这个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);
        }
    }
    

    看起来像这样:

    【讨论】:

    • 非常感谢兄弟。你解决了我的问题。
    • 不用担心很高兴我能帮上忙
    • 很高兴为您提供帮助,欢迎来到 Stack Overflow。如果此答案或任何其他答案解决了您的问题,请将其标记为已接受。
    猜你喜欢
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多