Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS timeout set up for webView loading?

Tags:

ios

timeout

It might be simple question but I haven't found the clear answer. I am loading a simple webview as following.. However, when signal is not good, it's just stuck there forever..

Could you please advise me the best way to set time out for this?

[TestViewController.webView loadRequest:requestObject]

like image 791
MomentH Avatar asked Aug 09 '26 11:08

MomentH


1 Answers

Set the timeout for the NSURLRequest

NSURLRequest *requestObject = [NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageAllowed timeoutInterval:10]; // timeoutInterval is in seconds

[TestViewController.webView loadRequest:requestObject]

Also see this SO post

like image 108
LJ Wilson Avatar answered Aug 11 '26 02:08

LJ Wilson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!