可能重复:
我可以在iPhone 中使用url方案打开手机应用程序吗
在应用程序中,我需要启动手机应用程序。我不想像下面的代码一样立即拨打电话:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://911"]];
只需拨打911。我想知道我是否可以启动手机应用程序。我试过这个代码:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://"]];
但它不起作用
请帮助我解决这个问题
你不能那样做。但是,如果将tel:
替换为telprompt:
,则会提示用户确认呼叫。
编辑:此外,@"a string"
是NSString
的语法文字。你不应该逃避引用。
试试这个代码:-
NSString *prefix = (@"tel://123");
UIApplication *app = [UIApplication sharedApplication];
NSString *dialThis = [NSString stringWithFormat:@"%@", prefix];
NSURL *url = [NSURL URLWithString:dialThis];
[app openURL:url];
注:电话号码应为仅的有效格式
希望它能帮助你