The following code works fine, but when I return to my application, it continues to execute the following code, but I don’t know why and how to stop it. I think this only happens in ios5.0: application thread - rootviewcontroller -> mainviewcontroller -> webview
The following code is called in the shouldstartloadrequest webview method in mainviewcontroller
@property (readwrite, retain) UIWebView *_loginWebView; ... .. - (void)viewDidLoad { [super viewDidLoad]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [_loginWebView loadRequest:requestObj]; }
// after the call is called whenever the webview receives a request to open the url
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{ //return no is a special case there is more code in the method which I am not showing here if ([[UIApplication sharedApplication] canOpenURL:myURL]) { [[UIApplication sharedApplication] openURL:myURL]; } else { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:newPath]]; } return NO; } //above is a special case }
header content -
<head> <meta name="viewport" content="width=device-width,initial-scale=1" /> <link rel="apple-touch-icon" href="images/...."/> <meta name="apple-mobile-web-app-capable" content="yes" /> <link rel="shortcut icon" href="favicon.ico" /> <script async="async" src="https://......."></script> <script type="text/javascript"> .......... </script> </head>
Jatin source share