确定UIPickerWheel是否正在滚动

嘿,有没有什么方法可以确定UIPickerView是滚动目前,我真的需要我的应用程序的function,这是非常重要的。 谢谢!

有一个UIPickerViewDelegate方法,基本上每次滚动选取器时都会触发

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component 

设置你的select器的代表,实现这个方法,看看会发生什么…

[编辑]现在好了,我明白你需要什么。 实现一个检查select器状态的计时器。

 checkTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(checkPicker) userInfo:nil repeats:YES]; 

在上面的委托方法中,存储上次select器被移动的时间。

 lastPickerDate = [[NSDate date] retain]; 

在checkPicker方法中,检查上次移动已经过了多less时间

 NSTimeInterval timeSinceMove = -[lastPickerDate timeIntervalSinceNow]; 

如果timeSinceMove较大,那么一些期望的值,例如0.5秒,将BOOL pickerMoving设置为false。 否则将其设置为true。 这不是检查移动的最精确的方法,但我认为它应该做这个工作…

有一个技巧来检测,但没有委托的方法/财产来检测是否滚动或不

  1. 以滚动的forms获取财产
  2. func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String?设置isScrolling为true func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? 或同等的方法
  3. func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)设置isScrolling为true func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int)

希望这可以帮助