tags:

views:

72

answers:

4

I have a UIView - which I am using as a makeshift toolbar. It contains several UIButtons. (Six, I think) in a horizontal row.

The fifth button over will only respond to [TouchUpInside] events when I click the left half of it - whereas all the other buttons work correctly.

I have gone crazy making sure there weren't any other views overlapping it, etc - and everything seems okay.

Any idea of how to investigate further? Is there any way to see an "event inspector" to see where the touch messages may be going?

A: 

Well you could try to use this technique with NSLog() to log events and get a sense of what might be happening. I'm not sure if there's a better way to log events:

http://stackoverflow.com/questions/2003201/observing-pinch-multi-touch-gestures-in-a-uitableview/2003781#2003781

Nimrod
A: 

Most likely, the other half is covered by a transparent view that obstructs it. See the frames of all sibling views of the button:

for (UIView *v in myButton.superview.subviews){
    NSLog(NSStringFromCGRect(v.frame);
}

And see if any of the frames above the button (the array is ordered from bottom to top) overlap with it.

If they don't, see if the whole window has any views covering the button.

executor21
Everything looked normal from this output - all views spaced 45 px apart and all buttons 37 px wide - no overlap. Thanks for the tip, though!
Brad
+2  A: 

The problem was as follows:

The "sixth" button was a "Info Light" type button. For some odd reason - even though the bounds of this button were clearly outside of the bounds of the offending "fifth" button - the "info light" button seems to acquire touches a bit outside it's bounding box.

When I either:

  1. Moved the "Info Light" button further away from the "fifth" button

-or-

  1. Changed the "Info Light" button to a regular (Round Rect) button

...the problem went away!

See the two rightmost buttons in this image:

alt text

Brad
A: 

I guess your superview bounds might be a bit too small? Try to change your superview background color to red or some vivid color and check its bounds.

tia