UIWebView loading time
I've got webView and I try to handle case with bad connection. WebView tries to load content during 5 mins without connection and sends error after.
How can 开发者_如何学JAVAI change time of loading to 1 min for example?
You may try performSelector:withObject:afterDelay:
When it starts loading:
- (void)webViewDidStartLoad:(UIWebView *)webView{
[self performSelector:@selector(stop_bad_link) withObject:nil afterDelay:60.0 ];
}
If loaded successfully:
- (void)webViewDidFinishLoad:(UIWebView *)webView{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(stop_bad_link) object:nil];
}
If its a bad link:
-(void)stop_bad_link{
if([webView isLoading]!=NO)[webView stopLoading];
}
精彩评论