变更记录

序号 录入时间 录入人 备注
1 2015-10-26 Alfred Jiang -
2 2015-12-18 Alfred Jiang -

方案名称

UIView \ UIButton - 独占响应事件

关键字

UIView \ UIButton \ 独占响应事件 \ 同时点击

需求场景

  1. 避免两个按钮(UIButton)很近的时候同时触发事件
  2. 避免同时点击多个按钮(UIButton)

参考链接

  1. IOS 开发两个按钮(button)很近的时候同时触发事件解决的方法(setExclusiveTouch)
  2. UIView独占响应事件

详细内容

_button1 = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
[self.view addSubview:_button1];
_button1.backgroundColor = [UIColor redColor];
[_button1 addTarget:self
             action:@selector(buttonsEvent:)
   forControlEvents:UIControlEventTouchUpInside];

_button1.exclusiveTouch = YES;

_button2 = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, 100, 100)];
[self.view addSubview:_button2];
_button2.backgroundColor = [UIColor greenColor];
[_button2 addTarget:self
             action:@selector(buttonsEvent:)
   forControlEvents:UIControlEventTouchUpInside];

_button2.exclusiveTouch = YES;

效果图

(无)

备注

results matching ""

    No results matching ""