Note that there are some explanatory texts on larger screens.

plurals
  1. PODisable touch events on certain areas of iPhone screen
    primarykey
    data
    text
    <p>I want to disable touches on all areas of the screen apart from a specific few points (e.g buttons). I.e. I don't want 'touchesBegan' to trigger at all when I tap anything other than a button. Calling </p> <pre><code> self.view.userInteractionEnabled = NO; </code></pre> <p>has the desired effect for not registering touches, but then of course I can't tap any buttons. I basically want the button to still work, <strong>even if there are 5 points touching the screen, i.e. all touch inputs have been used up, and the button represents the 6th.</strong> </p> <p>Is this possible?</p> <p>I've tried inserting a view with userInteraction disabled below my buttons, but it still registers touches when the user taps the screen. It seems the only way to disable touch registering is to do so on the entire screen (on the parent UIView). </p> <p>UPDATE: I've tried using gesture recognizers to handle all touch events, and ignore those that don't qualify. Here is my code: </p> <pre><code>@interface ViewController : UIViewController &lt;UIGestureRecognizerDelegate&gt; </code></pre> <p>...</p> <pre><code> - (void)viewDidLoad { [super viewDidLoad]; UIGestureRecognizer *allRecognizer = [[UIGestureRecognizer alloc] initWithTarget:self action:nil]; allRecognizer.delegate = self; [self.view addGestureRecognizer:allRecognizer]; } - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { CGPoint coords = [touch locationInView:self.view]; NSLog(@"Coords: %g, %g", coords.x, coords.y); if (coords.y &lt; 200) { [self ignoreTouch:touch forEvent:nil]; return TRUE; } return FALSE; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSLog(@"%i touch(es)", [touches count]); } </code></pre> <p>However the screen still 'reads' the touches, so if I place 5 fingers down, the 6th one won't trigger a button press... </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload