Touch events in UIViewController instead of UIView
I am having trouble getting a UIViewController subclass to handle touch events from one of the sub views. This is the hierarchy:
UIViewController | MYGeneric_UIVC | MyAppSpecific_UIVC----- UIView[view_all] | +-- UIView[view_top] (top section of screen) +-- UIControl subclass[view_middle] (middle section) +-- UIView[view_bottom] (bottom section)
The touch events have been working in view_middle (the UIControl subclass) but I realised that in order to modify the UILabel text in view_top and view_bottom to react to what's happening in view_middle, I should instead handle the events in MyAppSpecific_UIVC (as opposed to sending messages around using pointers and delegates which I've seen other people suggest, which seems a bit messy).
So I removed the 4 touch event handling methods from view_middle and added them to MyAppSpecific_UIVC. What I think should happen is that if view_middle doesn't handle the events then it should try again going up the hierarchy (view_all, then MyAppSpecific_UIVC).
But MyAppSpecific_UIVC never gets any touch events, and I also tried view_all but that didn't work either.
Perhaps the nib file links things might be wrong ? The file's owner is MyAppSpecific_UIVC. The File's owner's 'view' is pointing to 'view_all'.
Should the 'Sent Events' of the view_middle (UIControl) be pointing at anything in IB ?
Should view_all have User Interaction Enabled, or not (it is off) ?
I am loading the nib file from using:
nibObjects = [[NSBundle mainBundle] loadNibNamed:resource owner:self options:nil];
Any suggestions please ?
change your Uiview class as UIControll it will accept the touch events.