2ボタンを作成したいと思います。ボタンを押すと電話がかかります。私はこのコードを書いて動作しますが、問題はボタンが同じ番号を呼び出すことです。私は別の番号を呼びたいと思っています。 誰でも自分のコードを修正できますか?iPhoneで通話ボタンを作成しますか?
#define firstnumber @"1"
#define secondnumber @"2"
- (IBAction)first:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:firstnumber message:@"do you want to call?" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
}
- (IBAction)second:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:secondnumber message:@"do you want to call?" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
// the user cticlicked one of the OK/Cancel buttons
if (buttonIndex == 1)
{
NSLog(@"ok");
NSURL *url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"tel://%@", firstnumber]];
[[UIApplication sharedApplication] openURL:url];
[url release];
}
else
{
NSLog(@"cancel");
}
}
`
感謝の伴侶を。それはもう動作します:) – muhammedkasva