【问题标题】:Display UIAlertView before opening phone.app在打开 phone.app 之前显示 UIAlertView
【发布时间】:2012-01-18 16:13:38
【问题描述】:

我有一个带有按钮和按钮标签的地图视图。 在标签上,我有来自 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];
}

谢谢。

【问题讨论】:

    标签: ios objective-c uialertview nsurl phone-number


    【解决方案1】:

    我做到了。
    这就是你的做法:

    - (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 方法附加到您的按钮上,您就可以开始了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-07
      相关资源
      最近更新 更多