目前iOS与JS通信貌似只有两种方法:用webView的stringByEvaluatingJavaScriptFromString:方法主动获取,或者是shouldStartLoadWithRequest:回调被动接受,似乎没有其他的方式了
解决方案 »
- uinavigationcontroller导航获取上级view出现unrecognized selector错误
- 本人第一个作品,欢迎交流经验。
- 程序后台运行得时候怎样调用震动
- iphone sdk xcode程序中如何调用web service?
- UITableView如何响应触摸事件?
- core data 字段类型为integer 16就挂掉
- XCODE中如何根据注释生成规范的文档
- iPhone手机app下载时,如何让背景图片变成我app的icon
- Is it necessary to make a normal ios app show info in 3d ball using openGL?
- CCb是什么
- IOS开发我该如何学习?
- 关于@interface和@implementation,求解!
由于Ajax没有刷新当前页面,所以shouldStartLoadWithRequest回调不会被执行,这种情况只能通过修改web的代码来解决,思路是改变页面的window.location,你可以参考下这篇:http://stackoverflow.com/questions/5353278/uiwebviewdelegate-not-monitoring-xmlhttprequest
把自己需要的参数放在url里,在Ajax执行的时候去修改window.location
由于Ajax没有刷新当前页面,所以shouldStartLoadWithRequest回调不会被执行,这种情况只能通过修改web的代码来解决,思路是改变页面的window.location,你可以参考下这篇:http://stackoverflow.com/questions/5353278/uiwebviewdelegate-not-monitoring-xmlhttprequest
把自己需要的参数放在url里,在Ajax执行的时候去修改window.location
话又说回来,这种方式并不是拦截Ajax请求(无法拦截),只是在Ajax执行的时候通知你
可以尝试在这里处理。
-[NSURLCache cachedResponseForRequest:]2、再就是看看能否使用 NSURLProtocol 拦截。没其他方法了。
iOS 8 下,方法2会失效。