2010-08-26 66 views

回答

4

您必须在您的应用程序中重新创建拨号屏幕(不需要太长时间才能完成)。输入电话号码后,您需要通过执行以下操作启动电话呼叫:

NSString* theNumberYouGathered = @"9994441234"; 
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: [NSString stringWithFormatting: @"tel:%s", theNumberYouGathered]]]; 

注意这只适用于实际的手机,而不是模拟器。

要创建的拨号画面,您需要:

  • 与一组UIButton S(#秒1-9)创建一个XIB文件,UILabel显示当前输入的号码,并一个“呼叫”按钮。
  • 连接数字UIButton s的印刷机并将数字添加到您的ViewController上的本地变量NSString。用这个号码更新UILabel
  • 当按下呼叫UIButton时,取本地存储的#并将上述方法调用与它一起。
+0

我现在将对此进行测试 - 但如果这工作我会很高兴。 感谢您的及时回复。 – WaterBoy 2010-08-26 03:22:00

+0

@WaterBoy:我刚刚更新了一些我用来创建拨号程序的概述步骤。如果您还有其他问题,请随时询问。 – sdolan 2010-08-26 03:25:52

+0

它工作! 再次感谢 – WaterBoy 2010-08-26 03:36:51

3

你可以这样做:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:12125551212"]]; 

这将创建一个UIAlertView中提示用户拨打的电话号码或取消。

+0

它没有创建Uialertview – 2014-02-20 08:48:31

0

您可以使用下面的代码

NSString *phoneNumber = @"18000275749"; // dynamically assigned 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",phoneNumber]]];