解决方案 »

  1.   

    先用
    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self];  判断一下当前的链接。
    -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
        if ((([httpResponse statusCode]/100) == 2)) {
            // self.earthquakeData = [NSMutableData data];
            [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
            
            [ webView loadRequest:[ NSURLRequest requestWithURL: myUrl ]];
            webView.delegate = self;
        } else {
            NSDictionary *userInfo = [NSDictionary dictionaryWithObject:
                                      NSLocalizedString(@"HTTP Error",
                                                        @"Error message displayed when receving a connection error.")
                                                                 forKey:NSLocalizedDescriptionKey];
            NSError *error = [NSError errorWithDomain:@"HTTP" code:[httpResponse statusCode] userInfo:userInfo];
            
            if ([error code] == 404) {
                NSLog(@"网络图片不存在");
                webView.hidden = YES; //隐藏webView或者用本地默认图片代替
            }        
            
        }
    }
      

  2.   

    不知道楼主具体是怎么实现的,我是利用js实现的,在img标签中加上onerro,不只是不存在,要是访问出错也会座对应的操作
      

  3.   

    万分感谢楼上两位,因为访问的图片比较多,所以没有使用第一种方法,使用了楼二的onerror方法,虽然没有根本上解决我的问题,但是已经很有帮助了,谢谢谢谢,