views:

757

answers:

2

I have a view controller which creates multiple subviews on top of it. All subviews and the view controller accept touches. How can i communicate the touch point information to all the subviews on the screen? Keep in mind that each subview covers the entire screen so after a few additions its a bit like pages in a book. That is, any subviews below the top subview can't be touched directly by the user. I have tried using [self.nextResponder touchesBegan:touches withEvent:event] however this only sends the touch information from the top subview to the superview bypassing all other subviews on the screen. Thanks

+2  A: 

I would put another subview ontop of everything. This would grab all the touches that you were interested in and pass them back to the view controller. Your view controller would then iterate through all it's child UIViews, giving them the events.

i.e. something like

for (UIView *view in subviews)
  [view touchesBegan:touches withEvent:event];

though that's assuming that all the subviews you want to pass events to are children of your view controller.

deanWombourne
yes , this is the correct way to do.
Biranchi
A: 

Alternatively you can send NSNotification to all the subviews. And in the subvews class you can have a better control and can handle the notifications to perform some task.

Biranchi