UIPickerView, detect “rolling wheel” start and stop?

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

    You can use a SwipeGestureRecognizer on the picker. I assume this is not a perfect solution at all.

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        _pickerSwipeGestureRecognizer.delegate = self;
        [_pickerSwipeGestureRecognizer setDirection:(UISwipeGestureRecognizerDirectionDown | UISwipeGestureRecognizerDirectionUp)];
    }
    
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
        if([gestureRecognizer isEqual:_pickerSwipeGestureRecognizer]){
            NSLog(@"start");
        }
    }
    
    - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
        NSLog(@"end");
    }
    

提交回复
热议问题