2011-12-12 33 views
0

我有一个按钮上有按钮和标签的地图视图。 在标签上我有来自plist的电话号码。 电话号码的plist中的变量称为“storePhone”我实现了它这样:在打开phone.app之前显示UIAlertView应用程序

text4.text = myAnn.storePhone; 

我为按下按钮,打开phone.app用于拨打该号码此方法。 一切正常,但我想要一个UIViewAlert对用户说:“你要拨这个号码,你确定吗?”在phone.app打开之前。

我该怎么做?

这是我的按钮梅索德:

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

感谢。

回答

0

我做到了。
这是你如何做到这一点:

- (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为方法,以您的按钮,你是好去。

相关问题