Reputation: 181
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
Reputation: 236
Try set a delegate:
-(void)viewDidLoad
{
myWebView.delegate = self;
}
And add protocol UIWebViewDelegate:
@interface yourViewController : UIViewController <UIWebViewDelegate>
Upvotes: 1