在我的應用程序中,我有一個左右swipegesturerecognizers的webview。問題是當我放大webview。似乎swipegesturerecognizers令人不安的是webview的scrollview委託和webview縮放工程不好。我如何正確地做到這一點?iOS的webview swipegesturerecognizer和縮放
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeRightAction:)];
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
swipeRight.delegate = self;
[webView addGestureRecognizer:swipeRight];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
[webView addGestureRecognizer:swipeLeft];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return YES;
}
- (void)swipeRightAction:(id)ignored
{
NSLog(@"Swipe Right");
//add Function
}
- (void)swipeLeftAction:(id)ignored
{
NSLog(@"Swipe Left");
//add Function
}
我解決它改變上述的委託方法與此一:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
return YES;
}
更新的解決方案 – user3065901 2014-10-17 13:07:25
很高興你解決它!更好的佈局將是輸入您的解決方案_作爲答案。是的,你可以回答你自己的問題,甚至(48小時後)接受你自己的答案。這更有助於未來的用戶。你得到更多的代表,因爲人們可以同時提出你的問題和答案。 – matt 2014-10-17 13:14:02