【问题标题】:UIWebView Woes - Error 101UIWebView 问题 - 错误 101
【发布时间】:2011-11-17 09:54:59
【问题描述】:

UIWebView 不会加载(错误 101)以下 URL: http://afrikaans.news24.com/Sci-tech/Nuus/Rwanda-gaan-Suid-Afrikaanse-wild-invoer-20111116

我试过percentescapes 无济于事。请帮忙!

【问题讨论】:

    标签: ios cocoa-touch uiwebview


    【解决方案1】:

    试试这个:

    //Set the URL to go to for your UIWebView
    NSString *webAddressString = @"http://afrikaans.news24.com/Sci-tech/Nuus/Rwanda-gaan-Suid-Afrikaanse-wild-invoer-20111116";
    NSLog(@"show webAddressString: %@", webAddressString);
    
    //Create a URL object.
    NSURL *weburl = [NSURL URLWithString:webAddressString];
    [webAddressString release];
    //URL Requst Object 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:weburl];
    
    //load the URL into the web view.
    [aWebView loadRequest:requestObj];
    

    错误 101 是 The operation couldn’t be completed.,由未找到域、网络问题甚至对象分配(从 Google 搜索)导致。

    【讨论】:

    • 让它像这样工作,但不幸的是我无法对网址进行硬编码
    • 发现问题,字符串包含不可见的换行符
    • +1 天哪,这也是我的问题!!以为我快疯了。更新您的问题以反映修复可能会很好。如果你这样做了,我会+这个问题。 (差点用+0跳过这个问题)
    【解决方案2】:

    试试类似的东西

    NSString *unencodedURLString = @"http://afrikaans.news24.com/Sci-tech/Nuus/Rwanda-gaan-Suid-Afrikaanse-wild-invoer-20111116";
    NSString *encodedURLString = [unencodedURLString stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    
    //Create a URL object.
    NSURL *weburl = [NSURL encodedURLString];
    //URL Requst Object 
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:weburl];
    
    //load the URL into the web view.
    [aWebView loadRequest:requestObj];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-13
      • 2016-01-18
      • 2011-06-16
      相关资源
      最近更新 更多