So I'm having a little difficulty setting this up. I'm using this: UIWebView open links in Safari for the code but I can't seem to get it to work.
Here's my .h file:
#import <UIKit/UIKit.h>
@interface SecondViewController : UIViewController
{
}
@property (strong, nonatomic) IBOutlet UIWebView *webView;
@end
And here's my .m file:
#import "SecondViewController.h"
@interface SecondViewController ()
@end
@implementation SecondViewController
@synthesize webView = _webView;
- (void)viewDidLoad
{
[super viewDidLoad];
[_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http:m.youtube.com/user/haatfilms/uploads"]]];
[_webView setBackgroundColor:[UIColor clearColor]];
[_webView setOpaque:NO];
_webView.scrollView.bounces = NO;
_webView.scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
}
-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
if ( inType == UIWebViewNavigationTypeLinkClicked ) {
[[UIApplication sharedApplication] openURL:[inRequest URL]];
return NO;
}
return YES;
}
@end
And I think I've connected the UIWebView delegate:
But still, when I click on a link, it still loads in the UIWebView and not in Safari.
Can anyone shed some light as to why it won't work? Thank you so much