iOS App - Set Timeout for UIWebView loading

后端 未结 4 1499
小蘑菇
小蘑菇 2021-01-30 14:52

I have a simple iOS native app that loads a single UIWebView. I would like the webView to show an error message if the app doesn\'t COMPLETELY finish loading the initial page in

4条回答
  •  Happy的楠姐
    2021-01-30 15:04

    All of the suggested solutions are not ideal. The correct way to handle this is using the timeoutInterval on the NSMutableURLRequest itself:

    NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://web.site"]];
    
    request.timeoutInterval = 10;
    
    [webview loadRequest:request];
    

提交回复
热议问题