2011-09-20 50 views
0

在我認爲我的UITextView(在designMode中使用UIWebView)的弱長定製重新實現之前沒有用處,有沒有辦法處理/取消javaScript onKeyUp等事件?從UIWebViewDelegate中取消javaScript事件

AFAIK只有通過-shouldLoadRequest發送消息:& stringByEvaluatingScriptWithString :.但是,這些調用是異步的,並且在執行stringByEvaluatingScriptWithString時,javaScript事件處理程序已經退出它的函數:因此事件取消方法不起作用。

如果不是這個功能,實現shouldReplaceCharactersInString:似乎是不可能的。 :(

回答

1

也許你可以檢查我的開源實現一個「野生動物園象」瀏覽器: 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';"]; 
} 
+0

抱歉耽擱我想我設置成向我發送電子郵件更新,但我從來沒有收到任何我會嘗試看看在這個明天 – Anderson

+0

感謝您的答覆,我相信在你的情況基本上斷開了js事件處理程序,而是原生處理iOS touch事件。 – Anderson

+0

在我的情況下,iOS不允許在本地處理關鍵事件,因此不起作用。 – Anderson