UIPickerView里面的UITableView.tableFooterView不接收拖动触摸 [英] UIPickerView inside UITableView.tableFooterView doesn't receive drag touches

查看:160
本文介绍了UIPickerView里面的UITableView.tableFooterView不接收拖动触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在表格的页脚中有一个UIPickerView(从中我计划发出分页表格的请求 - 选择器将列出我导航的LARGE数据集的可用页面,并让用户直接跳到数据的任何页面)。

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 data set I'm navigating, and let the user jump straight to any "page" of the data).

我的选择器接收水龙头;如果我点击不是所选择的拾取器的行,它滚动到拾取器的中心空间。但是如果我拖动我的手指在选择器,我滚动TABLE,而不是选择器内容。

My picker receives taps; if I tap on a row of the picker that isn't the selected one, it rolls into the center space of the picker. But if I drag my finger on the picker, I scroll the TABLE, not the picker contents.

我试图在我的tableFooterView安装一个UIView子类,触摸,我可以...但不触及选择器。在选择器周围的触摸事实上触发UIView子类的 -touchesBegan

I tried installing a UIView subclass in my tableFooterView to see if I could catch touches, and I can... but not touches on the picker. Touches AROUND the picker do in fact fire that UIView subclass's -touchesBegan. But not ones on the picker itself.

推荐答案

这是最后的工作方式。

我把我的表变成UITableView的子类(称为PickerSensitiveUITableView)。

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

我实现了这个方法:

- (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;
}

现在当触摸发生在选择器的边界在表中!)它关闭了UITableView的可滚动性。

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.

它发生在一个更一般的解决方案将做一个类别在UIScrollView。问题不在于表与UIScrollView那么多,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...

这篇关于UIPickerView里面的UITableView.tableFooterView不接收拖动触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆