How can I get UIViews to propogates their touch events?

paddycobbett
paddycobbett used Ask the Experts™
on
Hi,

I've come across an issue with overlapping UIViews. Obviously the UIView that sits "on top" absorbs the touch events, however I need the UIView that sits underneath to recognize/respond to touch events also.

Please see the attached image.. I have two tabs, "More Info" and "OPUS", although they join up they are actually two different layers, and the "OPUS" tab sits on top. I have an invisible UIButton on the actual tab which when touched expands the panel (as in goes upwards!) However, I also have another invisible UIButton on the "More Info" tab which should make it expand upwards also although it is not responding, and am pretty sure is because it sits underneath the UIView of the other tab panel which is absorbing the touch events. I can think of a view hacked solutions to this, but is there a clean solution in which i could ideally instruct a UIView to propagate touch events? Or else could anyone suggest how they would resolve a similar dilema!?

Many thanks!
Screen-shot-2011-08-07-at-12.30..png
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think you are on the right track with a "view to propagate" all touch events.  Because of all your overlapping and different views on top of one another, you could put another view over the top of everything, then when this view is touched first get where the touch is and then you will know what the user "thinks they are touching".

It looks like an iPad app, so if you are handling rotation changes this option might get complicated.

I am also thinking that maybe the better way would be to not have things overlapping.  So that the touch events work properly, but this would be your choice and you would have to go back to the drawing board and account for each pixel properly.

Author

Commented:
Hi, thanks for responding!

Your suggestion of:

"you could put another view over the top of everything, then when this view is touched first get where the touch is and then you will know what the user 'thinks they are touching'."

.. was what I referred to by me thinking of a few hacked solutions to this! However I'd really rather not go down that route since this isn't the only example of overlapping uiviews that has caused me problems! Your other comment is interesting..

"I am also thinking that maybe the better way would be to not have things overlapping.  So that the touch events work properly, but this would be your choice and you would have to go back to the drawing board and account for each pixel properly."

I guess this would involve me having 2 uiviews for each tab/panel, i.e one for the tab and one for the panel itself? That way there wouldn't be any overlapping. This would result in simultaneously sliding 2 uiviews (the tab and it's panel) in response to touching the actual tab(?) It really doesn't feel natural (should really move as a whole) but do you suggest that this is the best (or only!) way to go?
do the tabs "More Info" and "OPUS" change your views above them?

What happens when your touch "the building" and "price list"?

This is an iPad app right?

Author

Commented:
Touching "the building" and "price list" doesn't have any effect on the tabs, they are visible all the times. Yes, this is an ipad application, and sorry to respond to your previous comment am not concerned about ipad rotation, the app only supports portrait orientation.

I'm not sure what you mean by:

"do the tabs "More Info" and "OPUS" change your views above them?"
Sorry I was thinking uitabview? How do these tabs work? What are they, uibuttons? and what comes up when they are touched?

Author

Commented:
Yes, they basically work like uitabviews, but custom built it so that it looks as the client wanted it.
I am still trying to understand the view set up especially as you have tabviews in there.  First if you have managed to get the UITAbviewController in there then congratulations.  I have looked at that and decided not to do it because it is not easy.

So you have 2 DIFFERENT UITabviews? Is this correct?  Each UITabView is connected to only 1 view?  This view is the whole screen thus causing the overlapping problem.

First my personal opinion is that TabViews were not meant to be used like you want.  But how about you use one tab view with 2 tabs?

Thus why does the customer want this? What feature do they want that the TabView has?  Normally the UITabView is the root view which allows you to have many tabs and a "more..." as well.  And it gives an easy method of moving between views.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial