问题
On iOS 8, the below code works fine, it can scroll with more inertia.
webView.scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
As for iOS 9 beta 3, this code is meaningless, even without an error.
Is this a bug or are there any other ways around?
Note: UIWebView's scroll rate can be changed two types on both versions.
回答1:
Update: this has been fixed but not deployed in iOS 9.3 (see workaround below). More detail here:
- https://bugs.webkit.org/show_bug.cgi?id=148086
- http://trac.webkit.org/changeset/188541/trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm
I had the same issue and it seems to be a bug in iOS 9.
The workaround is to set it in the will begin dragging delegate instead of at the time of instantiation:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
scrollView.decelerationRate = UIScrollViewDecelerationRateNormal;
}
回答2:
I also used to get sporadic crashes, then I set
webview.scrollView.delegate = nil
in deinit.
来源:https://stackoverflow.com/questions/31369538/cannot-change-wkwebviews-scroll-rate-on-ios-9-beta-9-3