jsem
jsem

Reputation: 181

open external links in safari.app from UIWebView xcode

i have created UIwebView and name it :webveiw in ViewController.h i add the following code to open external link in safari :

-(BOOL) webview:(UIWebView *)webview shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
    if ( inType == UIWebViewNavigationTypeLinkClicked ) {
        [[UIApplication sharedApplication] openURL:[inRequest URL]];
        return NO;
    }
    return YES;
} 

when run it does not working where i did wrong ??

Upvotes: 0

Views: 136

Answers (1)

Ivan Kramarchuk
Ivan Kramarchuk

Reputation: 236

Try set a delegate:

-(void)viewDidLoad
{
    myWebView.delegate = self;
}

And add protocol UIWebViewDelegate:

@interface yourViewController : UIViewController <UIWebViewDelegate>

Upvotes: 1

Related Questions