I have one UIWebView
in my app,
-(void)viewDidLaod{
NSURL *url = [NSURL URLWithString:@"some url string"];
NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadRevalidatingCacheData timeoutInterval:30.0];
myWbView.delegate = self;
[myWebView loadRequest:request];
if ([timer isValid]) {
[timer invalidate];
}else{
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(addSec:) userInfo:nil repeats:YES];
//counting seconds
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
if (webView.isloading){
NSLog(@"LOADING");//it takes 5-8 seconds in average keep logging this
}else{
NSLog(@"FINISH");//since the request started,8-15 seconds later this is logged out
}
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"LOAD FAIL: %@",error);
}
here's the webpage I am trying to load,
I put the webview controller in a pageViewController
that every time I swipe to the next page a new load request starts.
(I do stop any unfinished loading when the swiped out views dealloc, so it won't be blocking the web tread)
sometimes i got some error messages like:
As a newbie to app development, I totally have no idea what's wrong with my code, is it some thread got stuck or the webpage using JavaScript/HTML5 that matters the speed?
I had looked into the Flipboard app (iOS7 version) which uses webview to load content page,it responses immediately after user taps any post on it. Even if the loading speed of UIWebView
is normally slow, a faster performance is possible.
Any suggested guide link / background knowledge I should have known would be appreciated.
PS: Since another better stuff WKWebView
is only supported in iOS8 and later
(in my app WKWebView
loads in the same speed as UIWebView
, but scores higher at HTML5 test site),
I still need UIWebView for iOS7.