I want to make a phone call, and for this I use the code below.
- (void)callPhoneNumber:(NSString *)phoneNumber
{
UIWebView * webView2 = [[UIWebView alloc] init];
phoneNumber = [[phoneNumber componentsSeparatedByCharactersInSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]] componentsJoinedByString:@""];
NSURL * url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", phoneNumber]];
[webView2 loadRequest:[NSURLRequest requestWithURL:url]];
[self.view addSubview:webView2];
}
Before calling, I will ask the user to select an option using UIActionSheet. When the user selects a parameter, based on which I place a call.
The problem is that the above code works fine if I don't show UIActionSheetand place the call directly. It asks for a warning requesting user confirmation for making a call. But after displaying UIActionSheet, if I call the method above, it does not display confirmation confirmation.
, , Xcode, , . . , ?
- ? ?
EDIT: . . , - , . , .
NSString *phoneNumberURL = [NSString stringWithFormat:@"telprompt:%@", phoneNumber];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumberURL]];
: .
. . , .
# pragma mark - ALERT VIEW DELEGATE
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag == MY_TAG)
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Option" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Option1", @"Option2", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
}
}
#pragma mark - UIActionSheet Methods
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != actionSheet.cancelButtonIndex)
{
[self callPhoneNumber:@"1234567890"];
}
}