【发布时间】:2011-04-16 23:32:18
【问题描述】:
我有一个包含许多链接的嵌入式网站,但 webview 窗口相当小,以允许放大和缩小列表上方的较大图像。如果可能的话,我需要 webview 来响应进入带有第二个嵌入式 UIWebView 的新控制器视图的超链接。
【问题讨论】:
标签: iphone
我有一个包含许多链接的嵌入式网站,但 webview 窗口相当小,以允许放大和缩小列表上方的较大图像。如果可能的话,我需要 webview 来响应进入带有第二个嵌入式 UIWebView 的新控制器视图的超链接。
【问题讨论】:
标签: iphone
UIWebView 有一个委托,它允许您响应某些事件,例如加载新内容的请求。只需在您的委托类中实现以下内容
-(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;
}
}
【讨论】: