简体   繁体   中英

UIWebView in a UITableViewCell open link in a browser.

I have a ViewController that have a UITableView. UITableViewCell have an UIWebView and I want to open links in a browser. I have set UIWebViewDelegate to my ViewController but method:

 -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 

does not work. How do I open links in a browser?

If you want to open your links in safari

[[UIApplication sharedApplication] openURL[yourURL]];

EDIT:

you can try this to get the URL from the webview all you need to do is to have access to that webview

yourURL = webview.request.URL.absoluteString;

Found a related topic on this: Get current URL of UIWebView

为什么不只使用UIWebViewController,并告诉Cell在轻击操作中推送新的WebViewController。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM