views:

32

answers:

1

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 mainBundle] resourcePath]];

[myWebView loadHTMLString:htmlContent baseURL:baseURL];
[self.view addSubview:myWebView];

[myWebView release];

}

A: 

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.

Matt Long
Does not work on simulator or iPhone.
ed potter
I tested your exact code on my phone and it works fine. It *will not work on the simulator*.
Matt Long
Ouch. Ok, with no link, just a straight number. Works. Groan. Just crunching code. Ouch. OK, now HOW DO I ACCEPT this answer, as Jeriko so kindly pointed out above? There is just Add Comment, and Answer Question on my screen. No other options. I'm sure it's staring right at me!
ed potter
Got it, duh. The big CHECK! Ok, back to work. :-)
ed potter