当点击iOS中的按钮时,如何用号码打开iPhone通话屏幕键盘?

时间:2014-01-07 11:02:17

标签: ios

我的应用程序中的视图控制器中有调用按钮。当我点击通话按钮时,它会显示我的iPhone通话键盘上有一些号码。        我没有得到任何解决方案。请帮帮我。

感谢您

2 个答案:

答案 0 :(得分:1)

在你认为我之前,我不是Popeye提供了另一个答案。

直到我的回答。有几种方法可以做到这一点

// Pick one of the two ways from below, one will return you to the app afterwards the other will not.
// This version of of creating the number will open the dialer but will not return you to the app afterwards.
NSURL *phoneNumber = [NSURL urlWithString:[NSString stringWithFormat:@"tel://%@", yourNumberString]];

// Whilst this version will return you to your app once the phone call is over.
NSURL *phoneNumber = [NSURL urlWithString:[NSString stringWithFormat:@"telprompt://%@", yourNumberString]];

// Now that we have our `phoneNumber` as a URL. We need to check that the device we are using can open the URL.
// Whilst iPads, iPhone, iPod touchs can all open URLs in safari mobile they can't all 
// open URLs that are numbers this is why we have `tel://` or `telprompt://`
if([[UIApplication sharedApplication] canOpenURL:phoneNumber]) {
    // So if we can open it we can now actually open it with
    [[UIApplication sharedApplication] openURL:phoneNumber];
}

希望如果您有任何疑问,请帮助我们。

答案 1 :(得分:0)

iPhone SDK不允许您直接访问app中的拨号号码。因此,您无法执行此操作,但有一种方法可以实现此目的。

- >使用keyBoardType UIKeyboardTypePhonePad创建一个TextField(yourPhoneNumber)。

- > [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",yourPhoneNumber.text]]];

希望这会帮助你。