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
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;
}
精彩评论