I'm trying to display an HTML page inside WKWebView
, however, the scrolling doesn't decelerate when I scroll, it just stops:
The problem is not apparent when I try to scroll beyond the top bounds, but when I'm scrolling through the content, smooth scrolling/deceleration doesn't work. Sometimes, it can also act like the content is ending when I scroll down and hold, although the content continues at the bottom (it can be seen at some point at the video but here is a static image for clarification, look at the bottom of the screenshot):
I don't have any nested scroll views etc. There is just WKWebView
inside my view controller (just ignore the overlapping behind the navigation bar, I'll style it later):
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
CGRect frame = self.view.bounds;
frame.origin.y -= 64;
frame.size.height += 64;
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
webView = [[WKWebView alloc] initWithFrame:frame configuration:config];
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:webView];
[self reloadData]; //it just loads the static HTML page into the web view
}
What might cause this behavior and how can I prevent it?
I solved the problem: it wasn't related to the WKWebView
itself. It was due to some script/styling inside that particular HTML file. I've taken the main (text, images etc.) parts to a clean HTML file and the problem went away.