how to programmatically instantiate phone call from iPhone
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:@开发者_StackOverflow"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?
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.
精彩评论