2011-04-21 99 views
1

現在這是我有一個web視圖中處理手勢代碼:手勢,iPad的

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

這段代碼的目的是通過三個網頁視圖是並排在滾動視圖滾動。

它適用於第一個webView,但最終我會將該手勢放到所有的webViews上,如果我嘗試將它放到第二個上,它不適用於第一個。任何想法爲什麼和這個問題的可能的解決方案?提前致謝!

回答

1

也許手勢識別器將在託管UIWebViews的視圖中效果最好。瞧,你只需要一個識別器,這應該讓它更容易管理。

+0

謝謝Mike,我真的很感激 – Ctak 2011-04-21 18:15:57