[英]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.