8

这是一个简单的问题,但很难解决。

我有两个执行相同功能的按钮。

我为按钮设置了不同的触摸事件。虽然这有帮助,但仍然可以同时按下它们。在慢速连接上,它会更容易。

[vote1Btn addTarget:self action:@selector(voteUp:) forControlEvents:UIControlEventTouchUpInside];
[vote2Btn addTarget:self action:@selector(voteUp:) forControlEvents:UIControlEventTouchDown];
4

2 回答 2

25

exclusiveTouch两个按钮的属性设置为 YES。

如果这还不够,让每个按钮beginIgnoringInteractionEvents在其操作开始时调用共享应用程序对象,并endIgnoringInteractionEvents在其操作结束时调用。

于 2013-04-14T04:54:31.140 回答
0
for(UIView* v in self.view.subviews)
{
    if([v isKindOfClass:[UIButton class]])
    {
        UIButton* btn = (UIButton*)v;
        [yourButton setExclusiveTouch:YES];
    }
}

这会奏效!

于 2016-08-24T07:54:27.903 回答