单击后确认用户要拨打电话号码 [英] confirm user wants to call a phone number after click

查看:57
本文介绍了单击后确认用户要拨打电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示一个弹出窗口,询问用户在单击某个号码时是否要呼叫该号码.

I want to show a pop up that asks if the user wants to call the number when the user clicks on a number.

我该怎么做?目前,当我单击该号码时,它会自动将其呼叫.

How do I do that? Currently, when I click on the number, it calls it automatically.

推荐答案

创建一个将委托设置为self的UIAlertView,如果selectedButtonIndex是警报中是"按钮的buttonIndex,请拨打电话号码;否则,请拨打电话不要打这个电话.

Create a UIAlertView with the delegate set to self, and if the selectedButtonIndex is the buttonIndex of the yes button in the alert, call the number, if not, don't call the number.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Do you want to call..." delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert setTag:02];
[alert show];
[alert release];

- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    if (alertView.tag == 02 && buttonIndex != alertView.cancelButtonIndex) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://phonenumber"]];
    }
} 

这篇关于单击后确认用户要拨打电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆