【问题标题】:iPhone UIWebView - Open new UIWebView Controller from a hyperlinkiPhone UIWebView - 从超链接打开新的 UIWebView 控制器
【发布时间】:2011-04-16 23:32:18
【问题描述】:

我有一个包含许多链接的嵌入式网站,但 webview 窗口相当小,以允许放大和缩小列表上方的较大图像。如果可能的话,我需要 webview 来响应进入带有第二个嵌入式 UIWebView 的新控制器视图的超链接。

【问题讨论】:

    标签: iphone


    【解决方案1】:

    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;
        }
    }
    

    【讨论】:

    • 这是什么意思? [BrowserViewController openBrowserWithUrl:url]; ...这条线在我的项目中不起作用...有什么帮助吗?
    • Phlibbo...我已经用我的 viewController 替换了它...当我点击任何超链接时仍然无法工作:(
    • 您的视图控制器是否支持 openBrowserWithUrl?这不是标准的方法,你必须自己实现。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-01-26
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2011-12-01
    • 1970-01-01
    相关资源
    最近更新 更多