开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜