I’ve got a view that has to be presented both in landscape and portrait. The transition between different orientations is done by repositioning and resizing the subviews. One of the subviews is a button (plain UIButton
with an image background). When the interface rotates to landscape, the button starts misbehaving – it can only be tapped on its left part, the right part does not respond. When I move the button a bit to the left, the tappable part grows. The button should not be obscured by any other view, it’s clearly visible. When I override the hitTest:withEvent:
method in the parent view, I see that the taps in the “numb” part of the button result in nil
being returned. I think I have seen this behaviour once before, but unfortunately I’ve forgotten the source of the problem :) Any help?
Asked
Active
Viewed 690 times
2

zoul
- 102,279
- 44
- 260
- 354
1 Answers
4
Ah yes, I forgot to resize the view itself. Thus the button was on the boundary of the view and even though it was not clipped, the part lying outside the view frame was not considered for hit tests.

zoul
- 102,279
- 44
- 260
- 354
-
Could you add some more details? Did you mean the button's encompassing view didn't change with the rotation? – Danny May 23 '13 at 22:27
-
Yes, exactly that, @Danny. – zoul May 24 '13 at 04:07
-
Thanks for replying. I've been battling with a button wherein I re-assign the button's frame to a CGRect. The CGRect is defined at the place I want the button to be, but it doesn't interact with taps. If you found details that could help decipher which properties need to be set to match up with button interactivity, it would be much appreciated. Thanks! – Danny May 24 '13 at 05:15
-
@Danny, it helps to have an idea about the event handling chain, the way the events flow from outer views to the target view, hit detection and similar stuff. Then you can place breakpoints or logging statements into the chain and see where your touches get lost. I’m sorry I can’t offer a better advice. – zoul May 30 '13 at 12:18