代码之家  ›  专栏  ›  技术社区  ›  Altealice

重写-handlePan:在UIScrollView中

  •  5
  • Altealice  · 技术社区  · 14 年前

    在UIScrollView子类中重写-handlePan:可以吗?

    谢谢分享你的观点。

    2 回复  |  直到 14 年前
        1
  •  8
  •   Altealice    14 年前

    如果有人感兴趣,我所做的不是重写,而是禁用默认的UIPanGestureRecognizer,并添加映射到我的自定义处理程序的UIPanGestureRecognizer的另一个实例。

    为twerdster编辑:

    //disables the built-in pan gesture
    for (UIGestureRecognizer *gesture in scrollView.gestureRecognizers){
      if ([gesture isKindOfClass:[UIPanGestureRecognizer class]]){
        gesture.enabled = NO;
      }
    }
    
    //add your own
    UIPanGestureRecognizer *myPan = [[UIPanGestureRecognizer alloc] init...];
    //customize myPan here
    [scrollView addGestureRecognizer:myPan];
    [myPan release];
    
        2
  •  4
  •   ios-lizard    13 年前

    //disables the built-in pan gesture
    scrollView.panGestureRecognizer.enabled = NO;
    
    //add your own
    UIPanGestureRecognizer *myPan = [[UIPanGestureRecognizer alloc] init...];
    [scrollView addGestureRecognizer:myPan];
    [myPan release];