How to open UITextView web links in a UIWebView instead of Safari?

前端 未结 3 2010
孤独总比滥情好
孤独总比滥情好 2020-12-28 08:32

I\'m developing and iPhone 3.0 application. And I\'m trying to open web links in a UITextView into a UIWebView instead of Safari. But still no luck.

The UIText

3条回答
  •  执念已碎
    2020-12-28 09:12

    This is an old question but incase anyone is looking for an updated way of doing this.

    Assign your viewController that holds the UITextView as a delegate in your viewController's .m file and just add:

    -(BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange{
    
        //Do something with the URL
        NSLog(@"%@", URL);
    
    
        return NO;
    }
    

提交回复
热议问题