[英]How can I detect a touch up inside in my custom view?
我已经创建了UIScrollView的子类来实现我的一个自定义控件,目前一切正常。
但是,只要检测到Touch Up Inside事件(就像界面生成器一样),我希望能够调用方法的人是否知道我该怎么做?
因为UIScrollView
不能从UIControl
继承,所以这是不可能的。 但是,您可以通过在自定义UIScrollView
类中实现UIResponder
方法来中继滚动视图的触摸事件:
-(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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.