1

我得到以下错误和 webview 似乎是白色的并且停止工作了。尝试在网站上上传图片时。

Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0xaa18300 {NSErrorFailingURLKey=http://www.livebinders.com/images/icons/wait30trans.gif, NSErrorFailingURLStringKey=http://www.livebinders.com/images/icons/wait30trans.gif}

实际上,当我在“www.livebinders.com”网站上共享 url 时出现此错误。对于共享网址,我点击了不同的链接。当我在“www.livebinders.com”上上传图片时在网站上分享网址后。我的 webview 看起来是白色的,并且 webview 不再工作了。当我回到主屏幕,然后我来到 webview 屏幕时,它仍然看起来是白色的。

//我用来在网站上分享网址的这段代码

-(void) loadLivebinderItTool:(NSString *)url{
    NSLog(@"url string %@",url);
    //[_overlayView removeFromSuperview];

    [_webView stopLoading];
    NSString *urlLink;//media/add_url_to_binder

    urlLink = [NSString stringWithFormat: @"%@%@%@&description=image",BASE_URL_STRING,UPLOAD_SINGLE_URL, url];

    NSLog(@"url manager :%@", urlLink);
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:urlLink]];

    [_webView loadRequest:requestObj];

}

我用来在网站上上传图片的这段代码

-(void) loadDirectAttachView:(NSString *)data{
    NSLog(@"data string %@",data);
    [_overlayView removeFromSuperview];
    [_overlayView setHidden:YES];
    NSRange isRange = [data rangeOfString:@"Error" options:NSCaseInsensitiveSearch];
    if(isRange.location == 0) {
        [_webView reload];
        [Common showAlert:@"Error" message:data];
       // [self loadSelectedView ];
        return;
    }

    NSArray *codeArray = [data componentsSeparatedByString:@"/"];
    NSString *code = [codeArray objectAtIndex:codeArray.count-1];
    code = [code stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    //code= @"MTQ1Mzc4Mg==";
    NSData *data1 = [NSData dataFromBase64String:code];
    NSString *convertedString = [[NSString alloc] initWithData:data1 encoding:NSUTF8StringEncoding];
    NSLog(@"converted string %@",convertedString);
   [_webView stopLoading];
    NSString *urlLink;
    NSLog(@"converted string value %@",convertedString);
    urlLink = [NSString stringWithFormat: @"%@%@%@&description=write_here",BASE_URL_STRING,UPLOAD_SINGLE_MANAGER_URL, convertedString];

    NSLog(@"url manager :%@", urlLink);

    NSURLRequest *requestObj = [NSURLRequest requestWithURL:[NSURL URLWithString:urlLink]];

    [_webView loadRequest:requestObj];

}

在现场成功上传图像后,它会调用此操作完成方法

-(void) operationCompleted:(NSString*) data
{

    NSLog(@"after completion: %@",data);

     [_overlayView removeFromSuperview];
    [_overlayView setHidden:YES];

    if (_webView) {
         [_webView reload];
    }

        NSRange isRange = [data rangeOfString:@"Error" options:NSCaseInsensitiveSearch];
        if(isRange.location == 0) {
            [Common showAlert:@"Error" message:data];
    }

}

我发现问题出现在 operationCompleted: method 中。因为当它调用 [_webView reload]; 然后出现此问题,webview 屏幕显示为白色,webview 停止工作

4

0 回答 0