开发者

UIWebView loading time

开发者 https://www.devze.com 2023-04-11 06:58 出处:网络
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.

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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号