iOS使用UIWebView遇到Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101
现在在接触iOS开发,今天在调试一个界面加载web页面的问题,发现死活无法加载,浏览器里能正常打开,加上相应代码之后得到了错误信息为:
2013-04-18 15:05:06.446 Client_DEMO[22889:1a303] webview didFailLoadWithError <UIWebView: 0x18ff2160; frame = (18 70; 315 408); autoresize = W+H; layer = <CALayer: 0xc1140a0>> , and err is Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101.)”
加日志的办法为:
WebviewDelegat.h 代码如下:
#import <UIKit/UIKit.h>
@interface WebviewDelegate : NSObject <UIWebViewDelegate>
@end
WebviewDelegat.mm 代码如下:
#import “WebviewDelegate.h”
@implementation WebviewDelegate
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSString * str = [[request URL] absoluteString];
NSString *urlStr = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSArray * strArray = [urlStr componentsSeparatedByString:@":"];
if([strArray count]>2)
{
NSLog(@”webview for %@”,urlStr);
if ([[strArray objectAtIndex:0] isEqualToString:@”jscall”] ) {
//这里拦截做些本地的事情
}
return NO;
}else{
return YES;
}
}
- (void)webViewDidStartLoad:(UIWebView *)webView{
NSLog(@”webview webViewDidStartLoad %@”,webView.debugDescription);
}
- (void)webViewDidFinishLoad:(UIWebView *)webView{
NSLog(@”webview webViewDidFinishLoad %@”,webView.debugDescription);
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
//把出错信息打出来
NSLog(@”webview didFailLoadWithError %@ , and err is %@”,webView.debugDescription, error.debugDescription);
}
@end
通过UIWebView的setDelegate方法将其绑定。
网上搜索之后得知是urlencode有问题,仔细核实了一下url,发现url里有个参数值有竖线,于是知道了是竖线未转义导致。
比如: http://lizongbo.com/?chid=0|0|618119, 应该为:http://lizongbo.com/?chid=0%7C0%7C618119
解决办法很简单,对url的字符串做了个替换:
sUrl=replaceStr(sUrl,”|”,”%7C”);//不转义的话会报错,nd err is Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101.)”
参考:http://stackoverflow.com/questions/2028379/uiwebkit-error-101
iOS使用UIWebView遇到Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101的更多相关文章
- [ios] 定位报错Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error 0.)"
Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed. (kCLErrorDomain error ...
- 使用Parse内付费服务出现的Error Domain=Parse Code=146 "The operation couldn’t be completed. (Parse error 146.)
因为开发一个应用有个内付费去广告功能,介于苹果官方提供的方法没用过,感觉有些复杂,于是选用了第三方组件Parse来解决这个问题,简单易操作: Parse简化苹果官方内付费问题,使用方法分厂简单只有两个 ...
- Error Domain=NSOSStatusErrorDomain Code=1718449215 "The operation couldn’t be completed. (OSStatus error 1718449215.)"
是在录音时,recoreder的录音格式不对.
- iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed.
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 38 ...
- Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be completed.
地图定位 错误:使用CoreLocation获取地理位置信息,报错 Error Domain=kCLErrorDomain Code=0 "The operation couldn’t be ...
- Error Domain=NSURLErrorDomain Code=-999 “The operation couldn’t be completed.
转:http://www.wangzhengdong.com/blog/error-domainnsurlerrordomain-code-999-the-operation-couldnt-be-c ...
- didFailWithError: Error Domain=kCLErrorDomain Code=0 “The operation couldn’t be completed. (kCLError
This error also occurs if you have Scheme/Edit Scheme/Options/Allow Location Simulation checked but ...
- NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)"
原文: http://stackoverflow.com/questions/19874935/afnetworking-2-0-post-issue-cocoa-error-3840json-tex ...
- 【iOS】iOS Error Domain=NSCocoaErrorDomain Code=3840 "未能完成操作。(“Cocoa”错误 3840。)"
昨天遇到的这个问题,详细信息: ----->类和方法__25+[Manager noticeRequest:]_block_invoke399----->错误信息Error Domain= ...
随机推荐
- luogu P2114 [NOI2014]起床困难综合症 位运算 二进制
建议去uoj那里去测,数据比较强 位运算的题目,就得一位一位的分开考虑 然后枚举初始值的最高位是0 是1 的最终攻击 (二进制内)最高位是1肯定比次位是1次次位是1次次次位是1···的大吧,显然 然后 ...
- github issues的操作
https://help.github.com/en/articles/searching-issues-and-pull-requests 根据 reporter筛选issues https://h ...
- Docker operation
Docker 容器镜像删除 1.停止所有的container,这样才能够删除其中的images: docker stop $(docker ps -a -q) 如果想要删除所有container的话再 ...
- [转]VS“当前上下文中不存在名称“ViewBag”解决方法
原文链接:<VS"当前上下文中不存在名称"ViewBag",当前上下文不存在名称"model""-已解决> 自己的项目出现了错误 ...
- go 语言字典遍历
package main import "fmt" func main() { var countryCapitalMap map[string]string /*创建集合 */ ...
- [osg]osg自定义事件的理解
参考:http://blog.csdn.net/l_andy/article/details/51058907 添加自定义事件 首先osg在其内部通过osgGA::EventQueue类维护了一个事件 ...
- Beta冲刺
第一天 日期:2018/6/24 1 今日完成任务情况. 妥志福.牛瑞鑫: 完成任务:数据库设计完成数据导入成功 王胜海.马中林: 完成任务:代码规范检查 董润园.邓英蓉: 完成任务:平台基本功能黑盒 ...
- Linux中CentOS6.5 64位 系统下安装docker步骤
CentOS6.5 64位 (docker目前仅支持64位)内核必须在3.10及以上 1. uname -r 查看内核版本 2. 升级内核到3.10版本(带aufs模块) cd /etc ...
- linux编译安装mysql5.1.x
安装mysql,安装前准备 如果mysql用户不存在,那么添加mysql用户 groupadd mysql useradd -g mysql mysql mysql编译安装 make时间特别长 wge ...
- English trip -- VC(情景课)1 D
Read 阅读 Welcome! Meet our new student. His first name is Ernesto. 欧内斯托 His last name is Delgado. 德尔 ...