2009-08-01 99 views
2

有沒有辦法捕獲對UIWebView內鏈接的點擊。我想找出用戶點擊過的地址,但實際上並沒有進入頁面。UIWebView - 捕獲點擊

這可能嗎?

回答

5

是有一個委託方法你視圖控制器可以實現:

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

參考:

http://developer.apple.com/iPhone/library/documentation/UIKit/Reference/UIWebViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UIWebViewDelegate/webView:shouldStartLoadWithRequest:navigationType

+1

感謝。爲了將來的參考,你也必須把它放在方法中,否則它會計算不是點擊的加載請求:if(navigationType == UIWebViewNavigationTypeLinkClicked){/ *用url * /} – cannyboy 2009-08-02 09:52:23