拨号码

时间:2010-08-25 05:35:51

标签: iphone objective-c dialing

我读了一些关于如何在iPhone上以编程方式进行调用的参考资料,所以我把它放在我的代码中:

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"tel:0225225657"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

是正确的吗? 如果是,我怎么知道我的应用程序在模拟器中运行时拨打了该号码?

2 个答案:

答案 0 :(得分:2)

您的代码正常运行。你不能在模拟器中使用它。我的理由是:

UIApplication *app = [UIApplication sharedApplication];
NSString *urlString = [NSString stringWithFormat:@"http://www.google.com"];
NSURL *url = [NSURL URLWithString:urlString];
[app openURL:url];

这是您的代码,但使用http://www.google.com代替您的telphone网址。它打开Safari并转到谷歌。只需在您的设备上进行测试就可以了。

答案 1 :(得分:0)

不应该是:

NSString *urlString = [NSString stringWithFormat:@"tel://0225225657"];

...

相关问题