如何在UI Web视图中打开UITextView URL? [英] How to open a UITextView URL in UI Web View?

查看:63
本文介绍了如何在UI Web视图中打开UITextView URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程序中,UITextView包含一个URL.我想在UIWebView中打开此URL,而不是将其打开到Safari中? 我的UITextView包含一些数据以及一个URL.在某些情况下,没有的URL可以是多个.

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.

谢谢 桑迪

推荐答案

假定您具有以下实例,这些实例也添加到了UIView中:

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

UITextView *textView;
UIWebView *webView;

并且textView包含URL字符串,您可以将URL的内容加载到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];

这篇关于如何在UI Web视图中打开UITextView URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆