开发者

How can i bring up the iPhone call screen

I allow my user to selec开发者_运维问答t phone numbers in my application. How can I then bring up the iPhone call screen and then if possible, initiate the phone call?


You'll have to recreate the dial screen within your application (didn't take too long for me to do.) Once you have the phone number entered, you'll need to initiate the phone call by doing:

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

Note this will only work on the actual phone, and not the simulator.

To create the dialer screen you'll need to:

  • Create a xib file with a set of UIButtons (for #s 1-9), a UILabel to show the currently entered number, and a "Call" button.
  • Hook up the presses on the number UIButtons and add the digit to a local variable NSString on your ViewController. Update the UILabel with this number.
  • When the call UIButton is pressed, take the locally stored # and place the aforementioned method call with it.


You can do this:

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

which will create a UIAlertView prompting the user to call the number or cancel.


You can use below code

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜