This has been really driving me crazy. Web links work fine, but a phone number (I have tried a zillion combinations) do NOT work from my UIWebView. Any help MOST appreciated. Here's 3 more ways to do it. And none of them will dial a phone number.
- (void)viewDidLoad {
[super viewDidLoad];
CGRect webRect = CGRectMake(0.0f, 0.0f, 320.0f, 368.0f);
myWebView = [[UIWebView alloc] initWithFrame:webRect];
myWebView.backgroundColor = [UIColor clearColor];
[myWebView setOpaque:NO];
[[self myWebView] setDelegate:self];
NSString *htmlContent = [NSString stringWithFormat:
@"<html>"
"<body>"
"212-555-1212<br>"
"<a href=tel://212-555-1212>212-555-1212</a><br>"
"<a href=alo://212-555-1212>212-555-1212</a><br>"
"</body>"
"</html>"];
NSURL *baseURL = [NSURL fileURLWithPath:[[NSBundle main开发者_Python百科Bundle] resourcePath]];
[myWebView loadHTMLString:htmlContent baseURL:baseURL];
[self.view addSubview:myWebView];
[myWebView release];
}
Are you doing this on a device or in the simulator? If a device, is it a phone? If there is no phone app to open, it won't open. ;-) So the link won't work on the sim or a non-phone device.
精彩评论