zoukankan      html  css  js  c++  java
  • 如何响应UIScrollView的touchesBegan和touchesEnd消息

    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];
        }
    }
  • 相关阅读:
    CCPC-Wannafly Winter Camp Day4 Div1
    CCPC-Wannafly Winter Camp Day4 Div1
    CCPC-Wannafly Winter Camp Day4 Div1
    CCPC-Wannafly Winter Camp Day5 Div1
    Luogu 1603
    洛谷试炼场
    Codeforces 1100
    Codeforces 1099E
    Codeforces 1099
    Luogu 1093
  • 原文地址:https://www.cnblogs.com/hyamw/p/2139388.html
Copyright © 2011-2022 走看看