2010-09-24 71 views

回答

13

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

这是什么意思? [BrowserViewController openBrowserWithUrl:url]; ...这条线在我的项目中不起作用...有帮助吗? – 2011-05-23 12:54:49

+0

这意味着什么在评论中说,上面一行... – Phlibbo 2011-05-24 15:49:27

+0

Phlibbo ...我用我的viewController替换它...仍然不工作,当我点击任何超链接:( – 2011-05-25 06:11:05