UIPickerView, detect “rolling wheel” start and stop?

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

    As animation keys don't work, I wrote this simple function that works for detecting if a UIPickerView is currently moving.

    -(bool) anySubViewScrolling:(UIView*)view
    {
        if( [ view isKindOfClass:[ UIScrollView class ] ] )
        {
            UIScrollView* scroll_view = (UIScrollView*) view;
            if( scroll_view.dragging || scroll_view.decelerating )
            {
                return true;
            }
        }
    
        for( UIView *sub_view in [ view subviews ] )
        {
            if( [ self anySubViewScrolling:sub_view ] )
            {
                return true;
            }
        }
    
        return false;
    }
    

    It ends up returning true five levels deep.

提交回复
热议问题