在我认为 UITextView 的弱长自定义重新实现(在 designMode 中使用 UIWebView)无用之前,有什么方法可以处理/取消 javaScript onKeyUp 等事件吗?
据我所知,仅通过 -shouldLoadRequest: & stringByEvaluatingScriptWithString: 进行消息传递。但是,这些调用是异步的,并且在执行 stringByEvaluatingScriptWithString: 时,javaScript 事件处理程序已经退出其函数,因此事件取消方法不起作用。
如果没有这个功能,实现 shouldReplaceCharactersInString: 似乎是不可能的。 :(
最佳答案
也许你可以检查我的“类似 safari”浏览器的开源实现: https://github.com/sylverb/CIALBrowser
在这一个中,我确实重新实现了长按处理,并且为了禁用标准处理,我使用了这个:
- (void) webViewDidFinishLoad:(UIWebView *) sender
{
// Disable the defaut actionSheet when doing a long press
[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
}
关于ios - 从 UIWebViewDelegate 取消 javaScript 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7479713/