【问题标题】:Add swipeGesture to webView and stop ZoomIn and ZoomOut将 swipeGesture 添加到 webView 并停止 ZoomIn 和 ZoomOut
【发布时间】:2016-06-17 06:58:22
【问题描述】:

我需要将swipeGesture 添加到我的UIWebView,但是我需要停止该UIWebView 的放大和缩小

/*Swipe is enabled and zoom as well*/
    webViewPlayer.scalesPageToFit = true

当我将其更改为

webViewPlayer.scalesPageToFit = false
//zooming and swipe both disabled

编辑 1

我只想在没有ZoomInZoomOut 的情况下滑动手势到UIWebView

我尝试将swipeGesture 添加到UIWebViewself.view

【问题讨论】:

  • 在下面查看我改进后的答案。

标签: ios swift uiwebview uiswipegesturerecognizer


【解决方案1】:

试试这个...

因为UIWebView 中包含scrollview,所以你可以使用下面的方法来检查滚动是在哪个方向上。

这是检查滑动方向的另一种方法,因为滑动手势不能很好地工作UIWebView

scrollviewDelegateUIWebView

    webView.scrollView.delegate = self

ScrollView 委托

func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)
{
    if velocity.x < 0
    {
        print("Going Left!")
    }
    else if velocity.x > 1
    {
        print("Going Right!")
    }
}

【讨论】:

  • 检查我改进的答案。
猜你喜欢
  • 1970-01-01
  • 2019-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多