How to stop multiple pressing of UIButton?

Imagine what I have UIViewand I add 2 UIButtons.

I find that I can put my finger on one button, and then, while holding the first, I can touch the second button with another finger. Both buttons will show their UIControlStateHighlightedimages.

Is there a way to stop the second touch? I thought that multipleTouchEnabled = NOwas the answer, but it does not seem!

Any ideas?

+3
source share
4 answers

use the UIButton property named exclusiveTouch

+4
source
-(IBAction)button1Pressed {
    button2.enabled = NO;
}
-(IBAction)button2Pressed {
    button1.enabled = NO;
}

For touch.

Then for touching inward and touching outside.

-(IBAction)button1Lifted {
    button2.enabled = YES;
}
-(IBAction)button1Lifted {
    button2.enabled = YES;
}
0
source

when you insert the 1st button, in the Button IBAction method, disable the interaction of the 2nd button. (In the 1st line) and in the last line of the IBAction code of the 1st button, user interaction of the 2nd button is activated (in the last line). set IBAction to touch.

& vice versa.

0
source

add this property to each button \ n button.exclusiveTouch = YES;

0
source

Source: https://habr.com/ru/post/1761756/


All Articles