开发者

Load internet links from HTML string

开发者 https://www.devze.com 2023-03-16 04:51 出处:网络
I am using the function (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL [webView loadHTMLString:sourceCode baseURL:nil];

I am using the function (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL

[webView loadHTMLString:sourceCode baseURL:nil];

to load so开发者_运维知识库me source-code I wrote, with links to internet content. For instance :

<a href="http://www.google.fr/" title="Links to google">Google</a>

The string load well, but there is no way to access the google link then. Do you know what I am doing wrong ? Is there anything to do with the baseURL ?


your webpage must return a string that just contain http://www.google.com. If you need to use the link, you must modify the NSString that you receive to extract the right url!


Try setting the dataDetectorType for your webview like this:

webView.dataDetectorTypes = UIDataDetectorTypeLink;

Hope this helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消