views:

527

answers:

2

I have a very simple UIWebView with content from my application bundle. I would like any links in the web view to open in Safari instead of in the web view. Is this possible?

+8  A: 

Add this to the UIWebView delegate:

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    [[UIApplication sharedApplication] openURL:[inRequest URL]];
    return NO;
}
drawnonward
A: 

One quick comment to user306253's answer: caution with this, when you try to load something in the UIWebView yourself (i.e. even from the code), this method will prevent it to happened.

Mathieu Godart