28

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.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Sam
  • 799
  • 2
  • 8
  • 14

2 Answers2

90

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.

aero
  • 1,654
  • 1
  • 21
  • 31
arclight
  • 5,299
  • 1
  • 22
  • 26
38

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!

ytpm
  • 4,962
  • 6
  • 56
  • 113