Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS SDK, Text View - make links open in-app browser

Is it possible, using Text View's "Detection" for links, to let the user open the URL in an in-app browser, as opposed to switching to Safari? If there's not a setting for that option, how can I add a handler/event for when they tap a link, to open a WebView?

like image 262
benhowdle89 Avatar asked Apr 09 '14 17:04

benhowdle89


1 Answers

Try overriding textView:shouldInteractWithURL:inRange: in your UITextViewDelegate, and return NO to avoid forwarding the URL to the OS.

- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange
{
    // Load your webview

    return NO;
}
like image 77
michaels Avatar answered Oct 17 '22 01:10

michaels