I\'ve been searching far and wide through documentation regarding -webkit-overflow-scrolling: touch;, but I can only get it to work partially for my
I'm using WKWebView on an iPhone, iOS 12. I got no help with -webkit-overflow-scrolling:touch; But, I was able to implement a smooth scroll using a WKUIDelegate method for intercepting alert() calls. Instead of performing the alert(), I set the scrollView's contentOffset to a position value that's sent via the alert().
// in HtmlTable_VC.m
- (void)viewDidLoad
{
[super viewDidLoad];
wKWebView.scrollView.decelerationRate = UIScrollViewDecelerationRateFast;
// go figure -- faster deceleration seems to slow the scrolling rate
wKWebView.UIDelegate = self; // WKUIDelegate
// ...
NSString *htmlText = @"Your HTML page text here";
[wKWebView loadHTMLString:htmlText baseURL:[NSBundle mainBundle].bundleURL];
}
// WKUIDelegate
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message
initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
{
// if the message is numeric, smooth scroll the wkWebView
CGPoint scrollPoint = CGPointMake(0, [message intValue]);
[self->wKWebView.scrollView setContentOffset:scrollPoint animated:YES];
completionHandler();
// if not numeric, it was a real alert() interception, can process here
}
And the HTML file (Help.html):
Your HTML here
Stuff1
Stuff2
...
Go to Stuff1
Go to Stuff2
...