I'm trying to open links from UIWebView in safari, but have been unsuccessful so far. I am fairly certain I'm doing something wrong with the delegates. Can you guys take a look?
Here is what I have in my viewcontroller.m
(BOOL)webView:(UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *)request navigationType: (UIWebViewNavigationType)navigationType; {
NSURL *requestURL =[[request URL]retain]; if(([[requestURL scheme]isEqualToString:@"http"])&&(navigationType == UIWebViewNavigationTypeLinkClicked)){ return ![[UIApplication sharedApplication]openURL:[requestURL
autorelease]]; } [requestURL release]; return YES; }
sorry about the formatting. Anyway my first question is should the webView above be the same as the webView that I declared in my .h file?
My next question is about delegating the webview. This is my viewcontroller.h
http://jsfiddle.net/qJ8am/ (I know its not javascript, but it looks better here than in a blockquote)
and here is what I put in my .m viewdidload function (this was a guess i didn't know where to put it, or even if it should be self)
[webView setDelegate:self];
When running this project the code might as well not even be there, the links all still open in the app, not in safari. Can you guys help me with what I am doing wrong or give me some pointers on how to set up NSLog or something so I can see what is going wrong? Thanks for your help