打开phone.app之前显示UIAlertView [英] Display UIAlertView before opening phone.app
问题描述
我在地图上有一个按钮,按钮上有一个标签. 在标签上,我有一个来自plist的电话号码. plist中电话号码的变量称为"storePhone",我是通过以下方式实现的:
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;
我采用了这种方法来按下按钮并打开phone.app来拨打号码. 一切正常,但我希望UIViewAlert对用户说:您要拨打该号码,确定吗?"在phone.app打开之前.
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.
我该怎么做?
这是我的按钮方法:
-(IBAction)callToStore
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@", text4.text]];
[[UIApplication sharedApplication] openURL:url];
}
谢谢.
推荐答案
我做到了.
这是您的操作方式:
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];
}
}
将IBAction方法附加到您的按钮上,一切就很好了.
Attach the IBAction method to your button and you're good to go.
这篇关于打开phone.app之前显示UIAlertView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!