2012-03-31 52 views
-1

我以下面的方式开发一个调用程序。 我的主要目的是在文本框输入号码,每当我按下通话按钮将它转换如何从我的应用程序拨打电话?

成整数,然后进行调用action.in的Xcode是否有可能创造呼出一个

代码?

有没有可能阻止来电?

我在下面写代码的方式。

我的.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"]); 
} 

还怎么检查它执行主叫

请任意一个帮助,因为我是新开发此应用程序

感谢你,

+1

如何拨打电话以及如何阻止来电。 – 2012-03-31 10:31:59

回答

3

尝试使用tel协议。

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

您不能阻止任何来电。

2

您无法在您的应用中阻止任何来电。

相关问题