iPhone Dialing a Phone Number Part 1

Google+ Pinterest LinkedIn Tumblr +

Have you ever tried to dial a phone number from your application but it doesn’t work? Well, in this tutorial, you will learn how to dial a phone number directly from your application. In order for it to work, you need to have an iPhone that you can develop on (excluding the simulator). If not, nothing will happen when you will try to dial the number.

Create a new view based application named PhoneNumberTutorial. Open up PhoneNumberTutorialViewController.h and add in above @end, – (IBAction)callPhoneNumber;

Open PhoneNumberTutorialViewController.m and type this in:


// The designated initializer. Override to perform setup that is required before the view is loaded.

– (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {

// Custom initialization


return self;



– (IBAction)callPhoneNumber {

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”tel://1-800-692-7753″]];



// Implement loadView to create a view hierarchy programmatically, without using a nib.

– (void)loadView {




// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

– (void)viewDidLoad {

[super viewDidLoad];




// Override to allow orientations other than the default portrait orientation.

– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

// Return YES for supported orientations

return (interfaceOrientation == UIInterfaceOrientationPortrait);



– (void)didReceiveMemoryWarning {

// Releases the view if it doesn’t have a superview.

[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren’t in use.


– (void)viewDidUnload {

// Release any retained subviews of the main view.

// e.g. self.myOutlet = nil;


– (void)dealloc {

[super dealloc];



(I have to put in the unnecessary code because otherwise I don’t have enough words to publish the article).

Open up PhoneNumberTutorialViewController.xib and put a UIButton in the view and put ‘Call’ in the button. Control click from the button to the File’s Owner and select the callPhoneNumber event. Save it and go back to Xcode. When the button is pressed, it calls Apple. If you do not know how to put this application on your device, go to http://adcdownload.apple.com/iphone/iphone_developer_program_user_guide/iphone_developer_program_user_guide__standard_program_v2.5__final.pdf

to learn how.

Thanks for reading!

Part 2 is here: http://www.bukisa.com/articles/252157_iphone-dialing-a-phone-number-part-2

The source code can be found here: http://sites.google.com/site/iprogramiphones/bukisatutorials/dialingaphonenumberpart1

What kind of tutorial would you like next? Post your answer as a comment on this page.

Problems with coding? Email me @ edwardhinsa@gmail.com.

Have a dog and an iPod Touch and an iPhone? http://itunes.apple.com/us/app/whos-your-doggy/id332655618?mt=8

Subscribe to my tutorial RSS feed here: feed://sites.google.com/site/iprogramiphones/bukisatutorials/posts.xml


About Author

Leave A Reply