UIButton过于敏感 [英] UIButton oversensitive

查看:82
本文介绍了UIButton过于敏感的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在tableviewCellWithReuseIdentifier中定义了一个UIButton。

I have a UIButton defined within a tableviewCellWithReuseIdentifier.

该按钮有效,但非常灵巧。如果我只是点击该按钮,它将起作用。长时间按该操作都无法触发操作,即使它闪烁并表明已知道已按下该操作。为什么会这样呢?更重要的是,我该如何解决它。

The button works but it's very touchy. If I just tap the button it works. Pressing it any long fails to trigger the action, even though it does flash showing that it knows it was pressed. Why is this happening? More importantly, how can I fix it.

这是单元格中UIButton的代码。

Here is the code for the UIButton within the cell.

CGRect rect = CGRectMake(190.0, 2.0, 40.0, ROW_HEIGHT);
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTag:LBUTTON_TAG];
[button setFrame:rect];
[button addTarget:self action:@selector(leftbutton:) forControlEvents:UIControlEventTouchUpInside];
[button setAlpha:0.5];
[cell addSubview:button];


推荐答案

很远,但是:您是否有任何异步方法后台进程可能在点击和点击之间调用[tableView reloadData]?这可能会导致UITableViewCell的鼠标点击处理重置一些内部数据,使其忘记按钮内部的点击,这可能会导致它不触发UIControlEventTouchUpInside事件,因为它不记得该点击了。

A long shot, but: do you have any asynchronous background processes that might be calling [tableView reloadData] between tap-down and tap-up? That might cause UITableViewCell's mouse tap handling to reset some internal data that makes it "forget" the tap-down inside the button, which could cause it to not fire the UIControlEventTouchUpInside event since it doesn't remember the tap-down.

这篇关于UIButton过于敏感的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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