iPhone UIWebView - 从超链接打开新的UIWebView控制器 [英] iPhone UIWebView - Open new UIWebView Controller from a hyperlink
本文介绍了iPhone UIWebView - 从超链接打开新的UIWebView控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个嵌入式网站,其中包含许多链接,但网页视图窗口相当小,以允许放大和缩小列表上方的较大图像。如果可能的话,我需要webview将超链接响应到带有第二个嵌入式UIWebView的新控制器视图。
I have an embedded website that has many links but the webview window is fairly small to allow for a larger image above the list to be zoomed in and out. I need the webview to respond to hyperlinks into a new controller view with a second embedded UIWebView if at all possible.
推荐答案
UIWebView有一个代表,允许你回应某些事件,例如加载新内容的请求。只需在你的委托类中实现以下内容
The UIWebView has a delegate wich allows you to respond to certain events, e.g. a request to load new content. Just implement the following in your delegate-class
-(bool) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
//You might need to set up a interceptLinks-Bool since you don't want to intercept the initial loading of the content
if (self.interceptLinks) {
NSURL *url = request.URL;
//This launches your custom ViewController, replace it with your initialization-code
[YourBrowserViewController openBrowserWithUrl:url];
return NO;
}
//No need to intercept the initial request to fill the WebView
else {
self.interceptLinks = YES;
return YES;
}
}
这篇关于iPhone UIWebView - 从超链接打开新的UIWebView控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文