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];

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值