Search code examples
iosiphonecocoa-touchphone-call

Making a Button Call a Phone Number in iOS


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.


Solution

  • 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.