iOS调用js的方法 alert不能点击的原因

The gist is that the thread handling the JS from the stringByEvaluatingJavaScriptFromString: method and the thread handling the iOS alert view are probably blocking each other, making the “Close” button unresponsive.
it might be better to have the UIWebView trigger an UIAlertView rather than rely on UIWebView to handle the JS alert. The workaround above would be suitable for most debugging purposes though.
关键点在于,使用StrugByEngutyActudiaJavaScript执行JS方法的线程和执行iOS弹框视图的线程可能彼此阻塞,使得“关闭”按钮无响应。
最好让UIWebVIEW触发一个alert视图,而不是依赖于UIWebView来处理JS的alert。不过下面这种方式适用于大多数的调试了
NSString *functionStr = [NSStringstringWithFormat:@”postAction(%zd)”,action];
NSString *funcScript =[NSString stringWithFormat:@”setTimeout(function(){%@;},1)”,functionStr];
[_context evaluateScript:funcScript];

你可能感兴趣的:(ios,iOS)