curious123
curious123

Reputation: 53

open URL in Safari instead of webView

I have an app that populates an RSS feed in a table view. Selecting a row on the table, opens a new View with the whole post. My issue sometimes there are hyperlinks in the RSS feed. Clicking on the link opens the content in the same view instead of safari. I would like to open any links that are in the RSS feed in safari with an alert message about leaving the app. But I have no idea for to deal with this in my code. Any leads would be helpful. I am pasting my code for the DetailedView below.

    - (void)viewDidLoad {
[self.itemSummary loadHTMLString:[item objectForKey:@"summary"] baseURL:nil];
}


 - (id)initWithItem:(NSString *)theItem {
    if (self = [super initWithNibName:@"Detail" bundle:nil]) {  
        self.item = theItem;  
        self.title = [item objectForKey:@"title"];
    }  

    return self;  
}  

Upvotes: 0

Views: 440

Answers (1)

adedoy
adedoy

Reputation: 2273

try this code:

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

Upvotes: 4

Related Questions