如何从我的应用程序拨打电话? [英] How make an outgoing call from my app?

查看:100
本文介绍了如何从我的应用程序拨打电话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以下面的方式开发一个调用程序。
我的主要目标是输入文本字段中的数字,每当我按下调用按钮,它将

i develop a calling program in the below way. my main aim is enter the number in textfield and whenever i press the call button it convert

转换为整数,然后执行调用action.in xcode在那里是否有可能为拨出电话创建一个

into the integer and then perform calling action.in xcode is there any possibility to create a

代码?

是否有可能阻止来电?

我正在编写以下代码。

我的.h文件是

@interface mytextViewController : UIViewController
{             
  IBOutlet UILabel *enterphonenumber;           
    int currentNumber;        
}

@property(nonatomic,retain)IBOutlet UILabel *enterphonenumber;

-(IBAction)call;

-(IBAction)press:(id)sender;

@end

我的.m档案是

-(IBAction)press:(id)sender    
{    
    currentNumber = currentNumber*10 + (int)[sender tag];

    enterphonenumber.text = [NSString stringWithFormat:@"%i",currentNumber];    
}    

-(IBAction)call

{        
    int x =[enterphonenumber.text intValue];       

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:x]];
//[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"%tel:9963610177"]];
    NSLog(@"sample %@",[NSURL URLWithString:@"my phone number is calling"]);
}

还有如何检查它执行调用

And also how to examine it performs a calling

请任何帮助,因为我是开发此应用程序的新人

please any one help because i am the new to develop this application

感谢你,

推荐答案

尝试使用 tel 协议。

if ([[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
{
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%d", number]]];
}

您无法阻止任何来电。

这篇关于如何从我的应用程序拨打电话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆