Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a Button Call a Phone Number in iOS [duplicate]

I want to create a button that, when pressed, will call a phone number on the iPhone. I don't know if this is possible, but if it is I'd love for someone to help me with this.
I dont have any code for it, so someone would need to help me from start to finish.

like image 210
Sam Avatar asked May 23 '11 18:05

Sam


2 Answers

Try this out in your button action

-(IBAction)callPhone:(id)sender {     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://1115550123"]]; } 

Then in Interface Builder you should connect the TouchUpInside event to the previously declared action (callPhone:) and you are done.

like image 167
arclight Avatar answered Sep 20 '22 15:09

arclight


You can also go back to your original app when finish the call just by using this one instead:

-(IBAction)callPhone:(id)sender {     [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"telprompt://2135554321"]]; } 

Enjoy!

like image 38
ytpm Avatar answered Sep 20 '22 15:09

ytpm