Reputation: 11390
I have several UIViews and UIImageViews that are loaded inside a UIScrollView. Each "page", except the last one, in the scrollView works fine. The last view doesn't respond to touches, this is always the case no matter if there are 2 or 16 pages. All the pages are build in the same for loop using the same approach.
I have some UIButtons in the views and in the last page I can not get these to respond to touches. It seems that having a UIImageView with a .png with a transparent area on top of a view will block this view from reacting to touches. I think this is maybe what is going on, and some strange/miscalculated offset makes this only show itself in the last page.
Is there some way of debugging the "view stack". e.g. see which layers, UIViews etc. is being rendered to the screen so I can spot the one that is presumably covering my buttons.
In Flash AS3 I seem to remember that a touch event bubbling up the object hierarchy would carry with it, a reference to each view layer underneath the mouse. Is there something like this is the iPhone FrameWork?
Im all out of ways and ideas how to debug this any further. I checked the contentSize of the scrollView, tried coloring the background of each view to see if any of them are covering the buttons and in generally stepped through each line of code. But still no luck :/
Thanks for any suggestion or help given.
Upvotes: 1
Views: 2170
Reputation: 8685
Make sure your UIImageView and any other views that aren't supposed to receive touch events has the userInteractionEnabled
set to NO
. If they're set to YES, they're intercept touch events within their frames.
Upvotes: 1
Reputation: 71048
Low-wattage suggestion: You can in fact programmatically walk the view tree from your root, by getting [self subviews], all of which are UIView*s, and then do the same for each of them recursively, etc. You can dump out the frame or other debugging info using NSLog or whatever, and see if any of that information helps you.
Found this; it'll do this for you: http://ramin.firoozye.com/2008/12/11/easy-uiview-debugging-on-the-iphone/
Upvotes: 1