UIPickerView inside UITableView.tableFooterView doesn't receive drag touches

后端 未结 1 657
北海茫月
北海茫月 2021-01-20 03:06

I have a UIPickerView in the footer of a table (from which I plan to issue \"pagination\"-style requests for the table--the picker will list the pages available of the LARGE

相关标签:
1条回答
  • 2021-01-20 04:02

    Here's what ended up working.

    I made my table into a subclass of UITableView (called PickerSensitiveUITableView).

    The I implemented this method:

    - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event
    {
        UIView* result = [super hitTest:point withEvent:event];
    
        if ([result.superview isKindOfClass:[UIPickerView class]])
        {
              self.scrollEnabled = NO;
        }
        else 
        {
              self.scrollEnabled = YES;    
        }
        return result;
    }
    

    So now when the touch happens inside the bounds of the picker (actually ANY picker in the table!) it turns off the scrollability of the UITableView.

    It occurs to me a more general solution would be to do this as a category on UIScrollView. The problem isn't with tables so much as with the UIScrollView that UITableView is a subclass of...

    0 讨论(0)
提交回复
热议问题