Жесты в UIWebView, iPad

Прямо сейчас это код, который мне нужно обрабатывать жестами в webView:

    UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc]     initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[webView1 addGestureRecognizer:swipeRight];
//</code>

UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]     initWithTarget:self action:@selector(swipeLeftAction:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
[webView1 addGestureRecognizer:swipeLeft];


[super viewDidLoad];
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer     shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}

- (void)swipeRightAction:(id)ignored
{
NSLog(@"Swipe Right");
//add Function
}

- (void)swipeLeftAction:(id)ignored
{
NSLog(@"Swipe Left");

scrollView.contentOffset = CGPointMake(webView2.frame.origin.x,  webView1.frame.origin.y);
}

Целью этого кода является прокрутка трех веб-представлений, расположенных рядом в прокрутке.

Он работает для первого веб-представления, но в конечном итоге я захочу применить этот жест ко всем веб-представлениям, и если я попытаюсь применить его ко второму, он не сработает для первого. Любые идеи относительно того, почему и возможное решение этой проблемы? Заранее спасибо!


person Ctak    schedule 21.04.2011    source источник


Ответы (1)


Возможно, распознаватель жестов будет работать лучше всего в представлении, в котором размещены UIWebViews. Вуаля, вам понадобится только один распознаватель, что значительно упростит управление им.

person Mikey    schedule 21.04.2011
comment
Спасибо, Майк, я очень ценю это. - person Ctak; 21.04.2011