tony warriner
tony warriner

Reputation: 31

How do I stop multiple UIButton pressing?

Imagine I have a UIView and to that I add 2 UIButtons.

I find that I can put a finger on one button, then, holding the first, I can touch the 2nd button with another finger. Both buttons will show their UIControlStateHighlighted images.

Is there a way to stop the 2nd touch working? I thought that multipleTouchEnabled = NO was the answer, but seems not!

Any ideas?

Upvotes: 3

Views: 1804

Answers (4)

Amar Deep Singh
Amar Deep Singh

Reputation: 43

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

Upvotes: 0

anony
anony

Reputation: 49

use a property of UIButton called exclusiveTouch

Upvotes: 4

Matrix
Matrix

Reputation: 7623

when you tab on 1st button, in Button's IBAction method,make a user interaction of a 2nd button disabled.(On 1st line) and in last line of 1st button IBAction code, make 2nd button user interaction enabled.(on last line). set IBAction to touchDown.

& vice-versa.

Upvotes: 0

thyrgle
thyrgle

Reputation:

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

For touch down.

Then for touch up inside and touch up outside.

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

Upvotes: 0

Related Questions