LuisEspinoza
LuisEspinoza

Reputation: 8538

How do I enable user interaction in two overlapped UIViews?

I have two overlapping UIViews, and I want both to respond to user touches. At the moment, only the last view that was loaded responds.

How do I get both to respond to touch events?

Upvotes: 1

Views: 641

Answers (3)

LuisEspinoza
LuisEspinoza

Reputation: 8538

Finally, since I don't need that both responds at the same time, I made a workaround. I used the methods bringSubViewToFront: and sendSubViewToBack:. This methods made the work.

Upvotes: 1

thealch3m1st
thealch3m1st

Reputation: 106

If you call touchesBegan/Moved/Ended on super after you handle them I think you will achieve what you want.

Upvotes: 1

anka
anka

Reputation: 3857

you could provide a simple protocol which sends all touch events from the first view to the view in the background. So let the view in the background be a delegate of the first view would be a very simple approach.

Otherwise override the method touchesBegan:withEvent: of the view in the front and call the corresponding method of the view in the background.

Cheers, anka

Upvotes: 1

Related Questions