`
yidongkaifa
  • 浏览: 4059377 次
文章分类
社区版块
存档分类
最新评论

the operation could't be completed(webkitErrorDomain error 10

 
阅读更多
NSString *pathStr= [link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
經過實作之後,確定是可以用的。
参考:
NSString*pathStr=[link stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL*url=[NSURLURLWithString:pathStr];
NSLog(@"%@",url.host);//原本 host 是解析不出來的,現在可
以NSURLRequest*urlReq=[NSURLRequestrequestWithURL:url];

[webView loadRequest:urlReq];


今天遇到一個問題,就是網站如果使用MVC的開發模式,我們會遇到這樣類似的網址:"http://domain.com/25067/看完好想去旅行!青春18車票海報"。網頁的title塞到網址的最後面,這樣的做法雖然有利於SEO,但是 UIWebView 的 WebKit 去會把它當做是不合規格的網址,沒有辦法讀進網頁,會出現以下的錯誤訊息:
Error Domain=WebKitErrorDomain Code=101 "The operation couldn’t be completed. (WebKitErrorDomain error 101.)
以下是我的暫時的解決方式:

1.先判斷網址是否能夠連網。
2.如果不行,把網址最後的網頁title給拿掉。
NSString*link=@"http://domain.com/25067/看完好想去旅行!青春18車票海報";
NSString*pathStr=@"";
if([[UIApplication sharedApplication]canOpenURL:[NSURLURLWithString:link]]){
     pathStr=[NSStringstringWithString:link];
}else{
  NSMutableArray*aryx=[[NSMutableArrayalloc]initWithArray:[link componentsSeparatedByString:@"/"]];
     [aryx removeLastObject];
   for(inti=0; i<</span>[aryx count]; i++){
           pathStr=[pathStr stringByAppendingString:[NSStringstringWithFormat:@"%@/",[aryx objectAtIndex:i]]];}}
      NSURL*url=[NSURLURLWithString:pathStr];
    NSURLRequest*urlReq=[NSURLRequestrequestWithURL:url];
    [webView loadRequest:urlReq];
分享到:
评论

相关推荐

    微软内部资料-SQL性能优化3

    To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...

    acpi控制笔记本风扇转速

    could be incorrectly generated if the parent ResourceTemplate pathname places the template within a different namespace scope than the current scope. (BZ 7212) Fixed a problem where the compiler ...

    LCTF软件备份VariSpec™ Liquid Crystal Tunable Filters

    Previous revisions did not range-check the palette index number, and hard crashes could be produced if out-of-range values were supplied to this routine. Previous release 1.33b Release date: ...

    微软内部资料-SQL性能优化5

    A qualified operation is one that affects only specific rows that satisfy the conditions of a WHERE clause, as opposed to accessing the whole table. An index can have multiple node levels An index ...

    计算机网络第六版答案

    Hence, it becomes possible for the attacker to issue a command to all the nodes, that target a single node (for example, all nodes in the botnet might be commanded by the attacker to send a TCP SYN ...

    Senfore_DragDrop_v4.1

    doesn't extract the files and the files thus can't be copied/moved. This is caused by a quirk in WinZip; Apparently WinZip doesn't like IDataObject.GetData to be called before IDropTarget.Drop is ...

    Colo:[已弃用]颜色主题猎人

    科洛 Colo是一款应用程序,可帮助您发现颜色主题。 Colo的数据源基于libxml2库... Unresolved error Error Domain=NSCocoaErrorDomain Code=134100 "The operation couldn’t be completed. (Cocoa error 134100.)" 完

    servlet2.4doc

    Causes the next filter in the chain to be invoked, or if the calling filter is the last filter in the chain, causes the resource at the end of the chain to be invoked. doFilter(ServletRequest, ...

    IOS json 解析遇到错误问题解决办法

    主要介绍了iOS json 解析遇到error: Error Domain=NSCocoaErrorDomain Code=3840 &quot;The operation couldn’t be completed.解决办法,需要的朋友可以参考下

    Bochs - The cross platform IA-32 (x86) emulator

    XAPIC functionality could be enabled using new CPUID .bochsrc option. - Changed default CPU configuration (generated by configure script with default options) to BX_CPU_LEVEL=6 with SSE2 enabled....

    php.ini-development

    An empty string can be denoted by simply not writing anything after the equal ; sign, or by using the None keyword: ; foo = ; sets foo to an empty string ; foo = None ; sets foo to an empty string ;...

Global site tag (gtag.js) - Google Analytics