当前位置: 动力学知识库 > 问答 > 编程问答 >

iphone - touchesEnd not the same as UIControlEventTouchUpInside

问题描述:

How do i pass an event from a subview to 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: