开发者

How do I have my UIViewController respond to a non-touch event?

开发者 https://www.devze.com 2022-12-28 15:44 出处:网络
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 UIVi

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号