gpt4 book ai didi

ios - 如何禁止 WKWebView 的水平弹跳?

转载 作者:行者123 更新时间:2023-12-01 16:02:27 26 4
gpt4 key购买 nike

enter image description here

由于gif显示打击,我想禁止水平反弹,太丑陋了。

最佳答案

您可以使用它来阻止反弹:

    self.webView.scrollView.bounces = false

更新:

要仅禁用水平反弹,您可以使用以下代码:

首先将 webview 的 scrollview 委托(delegate)设置为 self
self.webView.scrollView.delegate = self

然后像这样实现它。
extension UIViewController: UIScrollViewDelegate{
public func scrollViewDidScroll(_ scrollView: UIScrollView) {
if(scrollView.contentOffset.x < 0){
scrollView.setContentOffset(CGPoint.init(x: 0, y: scrollView.contentOffset.y), animated: false)
}else if (scrollView.contentOffset.x >= scrollView.contentSize.width - scrollView.frame.size.width) {
scrollView.setContentOffset(CGPoint.init(x: scrollView.contentSize.width - scrollView.frame.size.width, y: scrollView.contentOffset.y), animated: false)
}
}
}

希望能帮助到你。

关于ios - 如何禁止 WKWebView 的水平弹跳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45050638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com