我还没找到问题的原因,但我找到了解决方案。
而不是像这样电话锚文字链接电话: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;
}
Lefakir, 你能忍受你是怎么做到的代码?使用newRequest调用UIWebView:loadrequest不会工作,因为消息仍然会出现。改变NSURLRequest不会工作,因为它是只读的。 – jjnguy 2011-02-22 19:19:09
Lefakir, 你可以提出你如何做的代码?使用newRequest调用UIWebView:loadrequest不会工作,因为消息仍然会出现。改变NSURLRequest不会工作,因为它是只读的。 – CodieMac 2011-02-22 19:19:32