开发者

iOS: Action Method to Dial Phone Number Upon User Tapping a Button

开发者 https://www.devze.com 2023-03-19 04:57 出处:网络
I would like to provide the functionality whereby a user can dial a phone number by开发者_JS百科 tapping a button next to a label that shows the number. I have the basic button action method:

I would like to provide the functionality whereby a user can dial a phone number by开发者_JS百科 tapping a button next to a label that shows the number. I have the basic button action method:

-(IBAction)Call:(id)sender{

//Define function
}

... but I don't understand how to trigger the dialing of the phone within the method.


[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://18005551234"]];


Swift 2.0:

func phoneCallPromptAction() {
    let url = NSURL(string: "telprompt://1111111111")
    UIApplication.sharedApplication().openURL(url!)
}

to ask user if he want's to call the number or just:

func phoneCallAction() {
    let url = NSURL(string: "tel://1111111111")
    UIApplication.sharedApplication().openURL(url!)
}

to make a call from you app directly.

0

精彩评论

暂无评论...
验证码 换一张
取 消