【问题标题】:WebView load requset failureWebView 加载请求失败
【发布时间】:2016-11-01 12:43:42
【问题描述】:

当我的 webView 第一次加载请求时,它是错误的。

错误域=NSURLErrorDomain 代码=-999 "(null)" UserInfo={NSErrorFailingURLStringKey=http://v.qq.com/iframe/player.html?vid=k034117nqr8&tiny=0&auto=0, NSErrorFailingURLKey=http://v.qq.com/iframe/player.html?vid=k034117nqr8&tiny=0&auto=0

但是当我滚动我的 tabview 时,我的 webView 会刷新,然后加载请求成功。为什么?谁知道呢?

【问题讨论】:

标签: ios webview


【解决方案1】:

我通过在 url 中添加一个参数来解决我的问题。然后每次都会请求不同的 url。

UIWebView *webView = [self createWebView];
webView.delegate = self;

NSURLComponents *urlCom = [[NSURLComponents alloc] initWithString:self.content];
NSString *timeString = [NSString stringWithFormat:@"%f",[[NSDate date] timeIntervalSince1970]];
NSURLQueryItem *item = [[NSURLQueryItem alloc] initWithName:@"aaa" value:timeString];
NSMutableArray *array = [urlCom.queryItems mutableCopy];
[array addObject:item];
urlCom.queryItems = array;
[webView loadRequest:[NSURLRequest requestWithURL:[urlCom URL]]];

【讨论】:

    猜你喜欢
    • 2018-12-04
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2018-03-27
    • 2018-03-03
    • 1970-01-01
    • 1970-01-01
    • 2017-05-13
    相关资源
    最近更新 更多