Marco
Marco

Reputation: 461

Phone call using a number in a UITextField

How can I make a phone call in my app to a number that's been input to a UITextField?

Upvotes: 1

Views: 1230

Answers (2)

slf
slf

Reputation: 22767

You should be able to call openURL: or openURL:options:completionHandler: with a "tel:" protocol. See the Phone Links section of the protocol reference. In iOS 3.x you will see a prompt though in iOS 2.x it will just dial.

Upvotes: 6

oscar castellon
oscar castellon

Reputation: 3138

NSString *callTextFiel = [NSString StringWithFormat:@"tel:%@", textField.text];

[[UIApplication SharedApplication] openURL:[NSURL URLWithString:callTextField]];

Upvotes: 1

Related Questions