How do I have my UIViewController respond to a non-touch event?
Working with iPhone SDK 3.2 --
I have a complex custom UIControl that handles touches on the child controls. In certain cases, I want the parent UIControl to pass an ev开发者_如何学运维ent to the UIViewController, which will then take action outside the control. How do I do this cleanly? Thank you!
I ended up handling this with
[control addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];
in the UIViewController
and
[self sendActionsForControlEvents:UIControlEventValueChanged];
in the UIControl
You can override hitTest:withEvent: in the UIControl and return nil when you determine that the touch should be handled by the parent.
精彩评论