为什么我的UITableView不响应touchesBegan? [英] Why does my UITableView not respond to touchesBegan?

查看:113
本文介绍了为什么我的UITableView不响应touchesBegan?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此方法

- (void)tableView:(UITableView *)tableView touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch = [[event allTouches] anyObject];
    if ([myPickerView isFirstResponder] && [touch view] != myPickerView) {
        [myPickerView resignFirstResponder];
    }
    [super touchesBegan:touches withEvent:event];
}

但我的tableView没有响应触摸(应用于视图工作,但这是由tableView覆盖的!)

but my tableView does not respond to touches (applied to the view works, but this is covered by the tableView!)

如果这是不可能的 - 是否还有其他可能捕获窗外触摸?

If this is not possible - is there any other possibility to capture "out of window" touches?

推荐答案

没有像 tableView:touchesBegan:withEvent:这样的委托方法。如果要为 UITableView 覆盖 -touchesBegan:withEvent:,则需要继承的UITableView 。像这样的大多数问题通常使用 UIGestureRecognizer 更好地实现。在上面,我可能会使用 UITapGestureRecognizer

There is no such delegate method as tableView:touchesBegan:withEvent:. If you want to override -touchesBegan:withEvent: for your UITableView, you will need to subclass UITableView. Most problems like this are often better implemented with a UIGestureRecognizer. In the above, I'd probably use a UITapGestureRecognizer.

这篇关于为什么我的UITableView不响应touchesBegan?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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