1

I have developed one iOS application. In my application I have add one UIWebView in all the screen for display ad (In footer all the screen).

I have load following html in UIWebView.

<html>
<head>
<meta http-equiv="refresh" content="5"/>
<meta name="viewport" content="width=device-width; minimum-scale=0.5;     maximum-scale=0.5; initial-scale=0.5 user-scalable=no"/>
<style> img {width : 100%; height : 100%} body {margin:0px; padding:0px;}     </style>
</head>
<body>
<a href='http://domainname:8080/ads/www/delivery/ck.php?n=a110ec2b&cb=INSERT_RANDOM_NUMBER_HERE' target='_blank'>
<img src='http://domainname:8080/ads/www/delivery/avw.php?zoneid=158&cb=INSERT_RANDOM_NUMBER_HERE&n=a110ec2b' border='0' alt=''/></a>
</body>
</html>


 [self.webViewFooterAd loadHTMLString:strFooterAdContent baseURL:nil];

strFooterAdContent is above html string.

Now, I have add on timer in my screen and on every 20 seconds I have refresh the webView. But it is not refresh.

I have use following code for refresh the webview.

[self.webViewFooterAd stopLoading];
[self.webViewFooterAd loadHTMLString:strFooterAdContent baseURL:nil];


 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:    (NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

    if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[request URL]];
        return NO;
    }

    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView{

}
- (void)webViewDidFinishLoad:(UIWebView *)webView{

}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
    NSLog(@"error : %@", error);
}

I have test it with iOS 9.0 and this is work proplery but in other iOS version (8.0, 8.1, etc...) it is not refresh or reload.

How to reload UIWebView with htmlString ? Please help me.

ChandreshKanetiya
  • 2,414
  • 5
  • 27
  • 41

0 Answers0