iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了iphone – 在UIWebview中检测滑动手势大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我是iPhone开发人员的新手,

我制作了epub阅读器并在我的webview中加载了epub的每一页

我想要的是,当用户第二次右键滑动手势然后我想导航到新页面时,我不想做第一次用户右手滑动手势时做任何事情.

UISwipeGestureRecognizer * swipeRight

有什么方法,比如

if(swipeRight.touch.count > 2)
{
  // do this
}

任何帮助都会得到满足.

提前致谢 !

编辑

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    float scrollViewHeight = scrollView.frame.size.height;
    float scrollContentSizeHeight = scrollView.contentSize.height;
    float scrollOffset = scrollView.contentOffset.y;

    if (scrollOffset == 0)
    {
        swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@SELEctor(swipeLeftAction:)];
        swipeUp.direction = UISwipeGestureRecognizerDirectionUp;
        swipeUp.numberOfTouchesrequired=2;
        swipeUp.delegate = (id<UIGestureRecognizerDelegate>)self;
        swipeUp.cancelsTouchesInView=YES;
        [_webview addGestureRecognizer:swipeUp];  
    }
    else if (scrollOffset + scrollViewHeight == scrollContentSizeHeight)
    {
        swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self  action:@SELEctor(swipeRightAction:)];
        swipeDown.direction = UISwipeGestureRecognizerDirectionDown;
        swipeDown.numberOfTouchesrequired=2;
        swipeDown.delegate = (id<UIGestureRecognizerDelegate>)self;
        swipeDown.cancelsTouchesInView=YES;
        [_webview addGestureRecognizer:swipeDown];

    }

解决方法

只需将uIGestureRecognizer子类附加到该视图并保持调用

UISwipeGestureRecognizer* rightSwipeRecognizer = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@SELEctor(someAction)];
rightSwipeRecognizer.numberOfTouchesrequired = 2;
rightSwipeRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
rightSwipeRecognizer.cancelsTouchesInView = YES;
[self.webView addGestureRecognizer:rightSwipeRecognizer]; // add in your webviewrightSwipeRecognizer

大佬总结

以上是大佬教程为你收集整理的iphone – 在UIWebview中检测滑动手势全部内容,希望文章能够帮你解决iphone – 在UIWebview中检测滑动手势所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。