2016-11-01 74 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]]];