Reputation: 3305
I have an iPhone application with some data and a small webView. Whenever user touches the webview it is supposed to open a Safari browser.
The problem is - when I close the opened Safari and start my application again it directly opens the full screen Safari. How can I prevent it?
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL* url = [request URL];
[[UIApplication sharedApplication] openURL:url];
return YES;
}
Before I was using the same code with if (UIWebViewNavigationTypeLinkClicked == navigationType)
conditon but with that the 1st touch was opening inside my small webview instead of already in fullscreen browser.
Any idea how can I fix it? Thanks in advance!
Upvotes: 0
Views: 425
Reputation: 3305
Had to escape to the option of "application does not run in the background" in app-Info.plist file. It solves the issue of app starting with safari after coming back from background..
Upvotes: 1
Reputation: 3431
Have you set a breakpoint in shouldStartLoadWithRequest: to see why it's being called again when the app is reopened? I'm surprised that it is.
You could set a flag in applicationDidEnterBackground when the app exits and check it in applicationDidEnterForeground and use that to guard the openURL request so that it's not called twice. That's a little messy though, I think you'd be better investigating what's calling shouldStartLoadWithRequest the second time.
Upvotes: 1