2009-12-31 57 views

回答

3

我還沒找到問題的原因,但我找到了解決方案。

而不是像這樣電話錨文字鏈接電話:myphonenumber,我寫異體:myphonenumber。因此,shouldStartLoadWithRequest方法被調用。我可以用allo:通過tel:在我的NSURLRequest對象中。

編輯,這裏是代碼:

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

     NSURL *requestURL = [[ request URL] retain]; 
     // Check to see what protocol/scheme the requested URL is. 

     if ( 
      // ([ [ requestURL scheme ] isEqualToString: @"http" ] || [ [ requestURL scheme ] isEqualToString: @"https" ]) && 
      (navigationType == UIWebViewNavigationTypeLinkClicked) 
     ) { 

     // Stats 
     [self recordTouch: [self tagToZone:[[webView superview] tag]]]; 

     // Substitution allo -> tel 
     NSURL *newURL = [[NSURL alloc] initWithString: [[[request URL] absoluteString] stringByReplacingOccurrencesOfString: @"allo:" withString: @"tel:"]]; 
     [requestURL release]; 

     //return YES; 

     // Launch 
     return ![ [ UIApplication sharedApplication ] openURL: [newURL autorelease]]; 
     } 

     // Auto release 
     [requestURL release]; 
     return YES; 
    } 
+0

Lefakir, 你能忍受你是怎麼做到的代碼?使用newRequest調用UIWebView:loadrequest不會工作,因爲消息仍然會出現。改變NSURLRequest不會工作,因爲它是隻讀的。 – jjnguy 2011-02-22 19:19:09

+0

Lefakir, 你可以提出你如何做的代碼?使用newRequest調用UIWebView:loadrequest不會工作,因爲消息仍然會出現。改變NSURLRequest不會工作,因爲它是隻讀的。 – CodieMac 2011-02-22 19:19:32