开发者

touchesEnd not the same as UIControlEventTouchUpInside

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜