3

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?

Rob Hruska
  • 118,520
  • 32
  • 167
  • 192

4 Answers4

4

use a property of UIButton called exclusiveTouch

anony
  • 49
  • 1
  • 2
  • I don't think that property was intended for that purpose. I went with this approach instead: http://stackoverflow.com/a/32267367/2359049 – NYC Tech Engineer Dec 22 '15 at 22:37
0

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

0
-(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;
}
0

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.

Matrix
  • 7,477
  • 14
  • 66
  • 97