views:

39

answers:

1

Please do tell how I can make a call with the iPhone.

Below is the code I have written, but nothing happens when the button is clicked. Is it a problem of the simulator and would it work on the phone, or is there any mistake in code?

- (void)applicationDidFinishLaunching:(UIApplication *)application { 

    UIButton *uiButton_G_obj = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    uiButton_G_obj.frame = CGRectMake(80, 30, 80, 30);
    [uiButton_G_obj addTarget:self action:@selector(buttonAction:)forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:uiButton_G_obj];
    [window addSubview:self.view];

    // Override point for customization after application launch
    [window makeKeyAndVisible];
}
-(void)buttonAction:(id)sender{
    NSLog(@"Inside button action");
    [[UIApplication sharedApplication]openURL:[NSURLURLWithString:@"tel:12125551212"]]; 
}

So, on a click of the button only

"Inside button action"

line is printed... But no phone call service is instantiated :( please help me out.

I just want to know, how can I instantiate a call service programmatically?

A: 

Yes this obviously does not work on the Simulator. It should work fine on a real device, where it will bring up a dialog and ask the user if he wants to start dialing that number.

St3fan
OK Thank YOu....
VinuthnaS