开发者

iPhone opening content from webView in Safari

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!


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.


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..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜