views:

318

answers:

1

Hey all,

I'm having a strange issue where a custom control I've built for the iPhone works perfectly when building in debug mode but only works partially when built in release mode.

The main wrapper view is a subclass of UIView and it contains a row of "buttons" that are added as subviews. The custom button class extends UIImageView and is overriding the touch methods with the following signatures:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

When building debug code, all 4 of these functions are called at the times you would expect, with a release build, nothing happens. I have logging in each of them and I'm not getting any log messages (other logging is working).

Another interesting thing, I have the touchesBegan/Moved/Ended methods overridden in the wrapper view class and they are working fine. I've tried commenting out those methods in the wrapper class to see if it had an effect on the buttons but it did not.

I've also tried changing the UIImageView class to be a subclass of UIButton instead but am having the same issue there, including any events like touchUpInside. They work in debug, but not release.

I've tried researching this issue as well as general event handling and have come up empty handed. Any ideas where to look next?

+2  A: 

I finally figured out the issue - the wrapper for the "button" items had a height of 0. In debug mode, the app figured out that the buttons were being touched even though they weren't inside the hit area of their parent view (clipsToBounds was defaulted to NO so the button items were still perfectly visible), in release mode, not so much.

Hopefully this can help save some people the head scratching and debugging time that I had to go through :) I've also posted this to a bug at Apple so hopefully it will be fixed someday.

Loktar