2012-03-31 95 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

您無法在您的應用中阻止任何來電。

相關問題