[英]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. 我已经创建了UIScrollView的子类来实现我的一个自定义控件,目前一切正常。
However what I'd like to be able to call a methods whenever a Touch Up Inside event is detected (just like interface builder) does anybody know how I could do this? 但是,只要检测到Touch Up Inside事件(就像界面生成器一样),我希望能够调用方法的人是否知道我该怎么做?
Because UIScrollView
does not inherit from UIControl
, this is not possible. 因为
UIScrollView
不能从UIControl
继承,所以这是不可能的。 You can, however, relay the scroll view's touch events by implementing the UIResponder
methods in your custom UIScrollView
class: 但是,您可以通过在自定义
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.