iphone - UIApplication 未启动以调用电话

标签 iphone cocoa-touch xcode

我有这个代码:

NSString *telURL = [NSString stringWithFormat:@"tel:1-%@",((UIButton*) sender).titleLabel.text];
telURL = [telURL stringByReplacingOccurrencesOfString:@"\n" withString:@""];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:telURL]];

但它不会启动拨号器应用程序来调用电话。

我检查了字符串 telURL,其内容是:“tel:[REDACTED]”,据我了解,这就是它需要的内容。

有什么想法吗?

编辑: 如果重要的话,我只是在模拟器上运行它。我几天内不会拥有物理设备。 (从下面的答案来看,这显然很重要)

最佳答案

你回答了你自己的问题。 tel: URL 不适用于 iPhone 模拟器和 iPod Touch(当然还有 iPad)。它仅适用于 iPhone。

关于iphone - UIApplication 未启动以调用电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5640683/

相关文章:

iphone - 为什么 NSCalendarDate 在 Simulator SDK 中,但不在 iPhone SDK 中?

使用枚举的 iPhone switch 语句

ios - Autorelease 池和在 iOS 下调用 release 的时间

c++ - 使用带有 OpenGL 的 PlayFile 苹果示例会卡住 OpenGL,直到播放声音结束

iphone - 使用日历作为日期选择器

iphone - 我们可以在Xcode中以编程方式将音频文件(mp3或任何文件)切成段(较小的部分)吗?

iphone UIAlertView 模式

iphone - 在 iOS 中,如何将图像嵌入到文本中(在 UITextView 中)?

ios - 在 iPhone 5 上以 3.5 英寸模式启动应用程序

cocoa - 在一个 CFReadStream 中设置 kCFStreamSSLValidatesCertificateChain 会导致其他 CFReadStreams 不验证证书链