Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overriding -handlePan: in UIScrollView

Is it ok to override -handlePan: in a UIScrollView subclass? i.e. my app won't get rejected from the app store?

Thanks for sharing your views.

Edit: what about calling -handlePan: in another method of my subclass?

like image 510
Altealice Avatar asked Jul 15 '10 07:07

Altealice


2 Answers

In case anyone is interested, what I did instead of overriding was disabling the default UIPanGestureRecognizer and adding another instance of UIPanGestureRecognizer which is mapped to my custom handler.

Edit for twerdster:

I did it like this

//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];
like image 155
Altealice Avatar answered Sep 22 '22 07:09

Altealice


You can make the code even shorter.

//disables the built-in pan gesture
scrollView.panGestureRecognizer.enabled = NO;

//add your own
UIPanGestureRecognizer *myPan = [[UIPanGestureRecognizer alloc] init...];
[scrollView addGestureRecognizer:myPan];
[myPan release];
like image 25
ios-lizard Avatar answered Sep 22 '22 07:09

ios-lizard