2016-11-01 72 views
0

当我的webView首次加载时,它是错误的。WebView加载请求失败

错误域= NSURLErrorDomain代码= -999 “(空)” 的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的,我的web视图会刷新,那么它将会是加载请求成功。为什么?谁知道呢?

+1

的可能的复制[什么是NSURLErrorCancelled = -999在IOS?](http://stackoverflow.com/questions/25390073/what-is-nsurlerrorcancelled-999-in-ios) – jcesarmobile

回答

0

我解决了我的问题,在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]]];