LoginSignup
32
29

More than 5 years have passed since last update.

UIButtonの同時押し禁止

Last updated at Posted at 2015-02-11

mikanのアプリで沢山ボタンがある画面にて、複数のボタンを同時に押すと大量の誤動作がありました。
UIButtonを複数使う時には、同時押しを禁止しておくと誤作動がなくなります。

同時押し禁止は、以下の1行を付けたすだけで出来ます。

// ボタン1, 2, 3 がある時
button1.exclusiveTouch = YES;
button2.exclusiveTouch = YES;
button3.exclusiveTouch = YES;

//Viewの中の全てのボタンについて
for (UIView * button in [myView subviews]) {
    if([button isKindOfClass:[UIButton class]])
        [((UIButton *)button) setExclusiveTouch:YES];
}

参考というかほぼ同じ:UIButtonの同時押し禁止
stackoverflow

32
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
29