Question

I have a scrollView on which I want to do an action when the pinch gesture is ended.

SampleController.h

@interface SampleController : UIViewController <UIPopoverControllerDelegate,UITableViewDelegate>{
    IBOutlet UIScrollView *mapScrollView;
}
@property (nonatomic, retain) IBOutlet UIScrollView *mapScrollView;
@end

SampleController.m

@implementation SampleController

@synthesize mapScrollView;

- (void)viewDidLoad {
    [super viewDidLoad];

UIPinchGestureRecognizer *pinchRecognizer = 
    [[UIPinchGestureRecognizer alloc] 
     initWithTarget:self 
     action:@selector(handlePinchFrom:)];
    [mapScrollView addGestureRecognizer:pinchRecognizer];
    [pinchRecognizer release];
}

- (void)handlePinchFrom:(UIPinchGestureRecognizer *)recognizer {
    if(recognizer.state == UIGestureRecognizerStateEnded)
       {
           NSLog(@"handleTapEND");
       }
    else
    {
        NSLog(@"zooming ...");
    }
}

- (void)dealloc {
    [mapScrollView release];
    [super dealloc];
}

@end

My problem is :

When I had the pinchRecognizer it blocks the scrolling of mapScrollView.

Is there an other way to detect the end of a scrolling or a zooming on a ScrollView ?

Thanks,

Bruno

Was it helpful?

Solution

I've found a solution :

I had a timer on my controller which proceed the action if a scroll or a dragg happend :

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mapTimer = [[NSTimer 
                            scheduledTimerWithTimeInterval:1.0f 
                            target:self 
                            selector:@selector(updateDisplay:) 
                            userInfo:nil 
                            repeats:YES] retain];
}

- (void)updateDisplay:(NSTimer*)theTimer {

    if(mapHasMoved)
    {
        NSLog(@"updateDisplay");
        [self updateProducts];
        mapHasMoved = FALSE;
    }
}

- (void)endZoomingOrScrollingHandler{

    mapHasMoved = TRUE;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top