Search code examples
iosobjective-ciphonephone-numberphone-call

Open the Phone (Call) with a button and a Text field/View (iPhone)


Would this be possible?

The app will have a button and a Text Field or a Text View.

The user types in the phone number in the Text Field or Text View. when the user is done the user presses the button which will open the Phone button and place the call to the number.

How would I do this? If possible please provide some code! :)

Thank you in advance!


Solution

  • Take a look at this code, This should work fine!

    -(IBAction)newuser:(id)sender;
    {
        NSString *URLString = [@"tel://" stringByAppendingString:textfield.text];
    
        NSURL *URL = [NSURL URLWithString:URLString];
    
        [[UIApplication sharedApplication] openURL:URL];
    }