检测滚动视图上的 PinchGesture END

发布于 2024-10-13 20:48:29 字数 1152 浏览 2 评论 0原文

我有一个滚动视图,我想在捏合手势结束时对其执行操作。

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

我的问题是:

当我有inchRecognizer时,它会阻止mapScrollView的滚动。

是否有其他方法来检测 ScrollView 上滚动或缩放的结束?

谢谢,

布鲁诺

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

¢蛋碎的人ぎ生 2024-10-20 20:48:29

我找到了一个解决方案:

我的控制器上有一个计时器,如果发生滚动或拖动,它会继续执行操作:

- (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;
}

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;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文