UIScrollView自己处理了这两个消息,但是并没有提供给UIScrollViewDelegate

因为需要支持用户点击ScrollView,从而选择其中的内容,只好从UIScrollView派生出一个新的类ClickableScrollView

重写touchesBegan和touchesEnd两个消息函数,转发出去

代码如下:

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

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

 

相关文章:

  • 2022-12-23
  • 2021-11-29
  • 2021-05-20
  • 2022-12-23
  • 2021-11-22
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-04-02
  • 2021-11-07
  • 2021-10-22
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
相关资源
相似解决方案