开发者

touchesEnd not the same as UIControlEventTouchUpInside

开发者 https://www.devze.com 2023-03-11 05:05 出处:网络
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

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.

0

精彩评论

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