开发者

How can I detect a touch up inside in my custom view?

I've created a subclass of UIScrollView to implement a one of my custom controls, at this point everything is working great.

However what I'd like to be able to call开发者_JAVA技巧 a methods whenever a Touch Up Inside event is detected (just like interface builder) does anybody know how I could do this?


Because UIScrollView does not inherit from UIControl, this is not possible. You can, however, relay the scroll view's touch events by implementing the UIResponder methods in your custom UIScrollView class:

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 
{   
    if (!self.dragging)
    {
        [self.nextResponder touchesEnded: touches withEvent:event]; 
    }       

    [super touchesEnded: touches withEvent: event];
}

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (!self.dragging)
    {
        [self.nextResponder touchesBegan: touches withEvent:event]; 
    }       

    [super touchesBegan: touches withEvent: event];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜