UIPickerView, detect “rolling wheel” start and stop?

前端 未结 7 1611
悲哀的现实
悲哀的现实 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:09

    Since animationKeys seems to not work anymore, I have another solution. If you check the subviews of UIPickerView, you'll see that there is a UIPickerTableView for each component.

    This UIPickerTableView is indeed a subclass of UITableView and of course of UIScrollView. Therefore, you can check its contentOffset value to detect a difference.

    Besides, its scrollViewDelegate is nil by default, so I assume you can safely set an object of yours to detect scrollViewWillBeginDragging, scrollViewDidEndDecelerating, etc.

    By keeping a reference to each UIPickerTableView, you should be able to implement an efficient isWheelRolling method.

提交回复
热议问题