【问题标题】:Detecting when UIPickerView has started scrolling/still scrolling?检测 UIPickerView 何时开始滚动/仍在滚动?
【发布时间】:2014-05-26 13:33:58
【问题描述】:

我一直难以确定 UIPickerView 何时开始滚动。

尝试了不同答案中提出的各种方法,似乎它们都不适用于iOS7。

我曾尝试使用 UITapGestureRecognizer,但 PickerView 无法处理它,但滑动和长按手势工作正常。

以下是有效的,但我真的想让 TapGesture 代替工作

pickerView.AddGestureRecognizer(new UILongPressGestureRecognizer(lp => 
        {
            PickerValueChanged = false;
        })
        {
            MinimumPressDuration = 0.1,
            CancelsTouchesInView = false,
            NumberOfTouchesRequired = 1
        });

任何想法将不胜感激

【问题讨论】:

    标签: c# ios xamarin uipickerview


    【解决方案1】:

    使用以下代码设法解决了我的问题

    pickerView.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
                {
                    DisableButton();
                    Console.WriteLine("tapped");
                })
                {
                    CancelsTouchesInView = false,
                    NumberOfTouchesRequired = 1,
                    ShouldRecognizeSimultaneously = delegate { return true; }
                });
    

    一旦选择器开始滚动,我就禁用按钮,然后在 pickerDataModel_ValueChanged 事件中我再次启用按钮。

    【讨论】:

    • 为我节省了很多时间!谢谢你。作为参考,这个link 也有帮助,我在转录 objC 时遇到了麻烦(委托 { return true;)
    猜你喜欢
    • 2018-08-30
    • 1970-01-01
    • 2016-01-31
    • 1970-01-01
    • 1970-01-01
    • 2012-03-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    相关资源
    最近更新 更多