0

ピンチジェスチャが終了したときにアクションを実行したいscrollViewがあります。

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

私の問題は:

pinchRecognizerを使用すると、mapScrollViewのスクロールがブロックされます。

ScrollViewのスクロールまたはズームの終了を検出する他の方法はありますか?

ありがとう、

ブルーノ

4

1 に答える 1

0

私は解決策を見つけました:

スクロールまたはドラッグが発生した場合にアクションを続行するタイマーがコントローラーにありました:

- (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;
}
于 2011-01-23T16:01:50.313 に答える