打开phone.app之前显示UIAlertView

发布于 2024-12-20 23:22:07 字数 503 浏览 3 评论 0原文

我在地图上有一个视图,其中有一个按钮和按钮上的标签。 标签上有来自 plist 的电话号码。 plist 中电话号码的变量称为“storePhone”,我以这种方式实现它:

text4.text = myAnn.storePhone;

我创建了这个方法来按下按钮并打开phone.app 来拨打号码。 一切都很好,但我想要一个 UIViewAlert 对用户说这样的话:“你要拨打这个号码,你确定吗?”在phone.app打开之前。

我怎样才能做到这一点?

这是我的按钮方法:

-(IBAction)callToStore
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", text4.text]];
    [[UIApplication sharedApplication] openURL:url];
}

谢谢。

I have a view on map with a button and a label on the button.
On the label i have phone number that comes from a plist.
The variable of the phone number in the plist called "storePhone" and i implemented it in this way:

text4.text = myAnn.storePhone;

I made this method for pressing the button and opening the phone.app for dialing the number.
Everything works great but i want a UIViewAlert to say to the user something like:"your going to dial this number, are you sure?" before the phone.app is open.

How can i do that?

This is my button methode:

-(IBAction)callToStore
{
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", text4.text]];
    [[UIApplication sharedApplication] openURL:url];
}

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想挽留 2024-12-27 23:22:07

我做到了。
您可以这样做:

- (IBAction)moreInfoViewAlert:(id)sender
{
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"חיוג לסניף"
                                                  message:@"הנך עומד/ת לבצע חיוג, האם את/ה בטוח?"
                                                 delegate:self
                                        cancelButtonTitle:@"ביטול"
                                        otherButtonTitles:@"חיוג", nil];
    [message show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"חיוג"])
    {
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", text4.text]];
        [[UIApplication sharedApplication] openURL:url];
    }
}

将 IBAction 方法附加到您的按钮,然后就可以开始了。

I did it.
This is how you do it:

- (IBAction)moreInfoViewAlert:(id)sender
{
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"חיוג לסניף"
                                                  message:@"הנך עומד/ת לבצע חיוג, האם את/ה בטוח?"
                                                 delegate:self
                                        cancelButtonTitle:@"ביטול"
                                        otherButtonTitles:@"חיוג", nil];
    [message show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];

    if([title isEqualToString:@"חיוג"])
    {
        NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", text4.text]];
        [[UIApplication sharedApplication] openURL:url];
    }
}

Attach the IBAction method to your button and you're good to go.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文