从iPhone应用程序拨打电话

Aks*_*hay 3 iphone call ios

可能重复:
从我的应用程序拨打iphone电话

我想从我的iPhone应用程序拨打给定号码的电话.你能建议一个最好解释它的好教程或告诉我这个过程吗?

iNo*_*oob 9

你可以试试 :

NSURL *phoneNumberURL = [NSURL URLWithString:@"tel:80001212"];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
Run Code Online (Sandbox Code Playgroud)


小智 6

NSString* phoneNumber=TextFiled Name
    NSString *number = [NSString stringWithFormat:@"%@",phoneNumber];
    NSURL* callUrl=[NSURL URLWithString:[NSString   stringWithFormat:@"tel:%@",number]];

        //check  Call Function available only in iphone
    if([[UIApplication sharedApplication] canOpenURL:callUrl])
    {
        [[UIApplication sharedApplication] openURL:callUrl];
    }
    else
    {
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"ALERT" message:@"This function is only available on the iPhone"  delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
                          [alert show];
                         [alert release];
                    }    
    }
Run Code Online (Sandbox Code Playgroud)