长按 link 时的 UIWebView 自定义 UIActionSheet 菜单

UIWebView custom UIActionSheet menu when long press on a link

我在 UIWebView 上长按 link 时实现自定义菜单。

为了防止 iOS 默认菜单,我正在使用:

-webkit-touch-callout:'none'

在 iOS 6、7 中一切正常:显示我的自定义菜单而不是默认的 UIWebView。但是在 iOS 8 中,一个奇怪的行为发生了。

在iOS8中,我自己的菜单显示后,我松开触摸,link正在UIWebView中加载。

我将 UIWindow 子类化,覆盖 sendEvent: 并查看不同之处:

当我的菜单开始显示时,我尝试从 javascript 触发 touchcancel,但没有成功。

这种情况有什么解决办法吗?

对于那些将来可能担心的人,我设法通过一个棘手的 hack 来克服这种情况:

CGPoint currentOffset = webview.scrollView.contentOffset;
[webview.scrollView setContentOffset:CGPointMake(currentOffset.x, currentOffset.y +1) animated:NO];
[webview.scrollView setContentOffset:currentOffset animated:NO];