views:

607

answers:

1

Hi there,

In my iPhone app an UITextView is containing an URL. I want to open this URL in an UIWebView instead of opening it into safari? My UITextView contains some data along with an URL. In some cases the no. of URLs can be more than one.

Thanks Sandy

+3  A: 

Assuming you have the following instances, that are also added to your UIView:

UITextView *textView;
UIWebView *webView;

and textView contains the URL string, you can load the contents of the URL into webView, as follows:

NSURL *url = [NSURL URLWithString:textView.text];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[webView loadRequest:req];
pythonquick
Thanks for the response pythonquick but I am facing a different situation in my case UITextView does contains some text data along with an URL in some cases the number of URLs can be more than one.
sandy
OK, so if you have more than one URL within the UITextView's text, what should happen to the UIWebView? In which circumstances should the UIWebView load which URL?
pythonquick