How do i pass an event from a subview to开发者_JAVA技巧 trigger UIControlEventTouchUpInside of its superview(a subclass of UIControl)? The subview has a triangular area of a certain size. If I remove my finger from within the triangle I want the UIControl superview to trigger its action. I tried to forward touchesEnd from the subview to the superview with nextResponder but it didn't work.
To programmatically fire an event on a UIControl, use this method:
- (void)sendActionsForControlEvents:(UIControlEvents)controlEvents
for example:
- (void)touchUpInside {
// will need to cast superview to UIControl
[[self superview] sendActionsForControlEvents:UIControlEventTouchUpInside];
}
more info on this method in the docs.
精彩评论