UIPickerView, detect “rolling wheel” start and stop?

前端 未结 7 1619
悲哀的现实
悲哀的现实 2020-12-18 04:30

I just discovered that if I do the following:

  1. Click the button that animates a UIPickerView into my view
  2. Quickly start the wheel rolling
7条回答
  •  醉话见心
    2020-12-18 05:08

    Expanded @iluvatar_GR, @Robert_at_Nextgensystems answer

    Used Gesture, UIScrollView isDragging or isDecelerating.

    // Call it every time when Guesture action.
    @objc func respondToSwipeGesture(gesture: UIGestureRecognizer) {
        // Changes the button name to scrolling at the start of scrolling.
        DispatchQueue.main.async {
           self._button.setTitle("Scrolling...", for: .normal)
           self._button.isEnabled = false
           self._button.backgroundColor = Utils.hexStringToUIColor(hex: "FF8FAE")
        }
    
        // Indication according to scrolling status
        _datePicker.waitTillDoneScrolling(completion: {
            print("completion")
            DispatchQueue.main.async {
               self._button.setTitle("Completion", for: .normal)
               self._button.isEnabled = true
               self._button.backgroundColor = Utils.hexStringToUIColor(hex: "7CB0FF")
            }
        })
    }
    

    [SWIFT4] Share Example Source link!

    enter Sample Source link

    • Reference : How to recognize swipe in all 4 directions

提交回复
热议问题