How do I limit touches to a specific region or UIView?
In other words, I have a UIButton on the view but it seems to be disabled by the touches.
I should also write that the touches do what I want, but, like I said, I lost control of the UIButtons.
@Implementation
...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
...
}
I solved my problem…
(My error) I made a smaller UIView with the UIButtons positioned outside of it. The subview was attached to that UIView. (I could see the buttons, but I couldn’t even press them)
Solutions(2 of them worked):
- addSubview of UIButtons to self.view
- or… enlarge the smaller UIView to 340 x 480.
If your view (where you defined
touchesBeganet al.) does not forward the touches to the next responder in the responder chain (among which there are your buttons), you could try to call [super] in all of those methods, i.e.:and the same for the other methods. See also the discussion here.