Home > Development, Tips > Touch events on the hidden statusbar

Touch events on the hidden statusbar

I spent a lot of time figuring out why a touch event is not passed to an UIButton located at (0, 0) whose size is 20 x 20 on the Simulator. 

I created an UIButton programmatically and added an event hander by using

addTarget:self  action: @selector(buttonTouchUpInsideHandler:) forControlEvents:UIControlEventTouchUpInside

 Of course I added

- (void) buttonTouchUpInsideHandler: (id)sender

I set a break point inside “buttonTouchUpInsideHandler” mehtod, but it was never hit.

So I implemented “touchedEnded” for the button’s parent UIView. While clicking (touching) the parent UIView, I happened to find that any touch event whose y-position is lower than 20 is not passed to the parent view’s “touchesEnded” method.  I immediately realized that that’s the height of the hidden status bar.

I tested the same code on my iPhone, but it was working perfectly. The button got a touch event and its touch handler was called.

It seems that it is a bug in the Simulator.  So in case you encounter the same problem, don’t waste you time!!

I also found this article:
https://devforums.apple.com/message/132010#132010

  1. No comments yet.
  1. No trackbacks yet.