我想做以下事情。我有一系列对象(企业),每个企业都有自己的详细信息,包括他们的电话号码。
我知道如何在Objective-C中进行调用,但我不知道如何动态更新数字。我有一个Details类(.h和.m),我已将tel声明为变量。
所以拨打电话我会在下面作为例子使用
-(IBAction)MakePhoneCall:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:123456"]];
}
我使用DetailViewController,因此我有一个已填充的业务列表,并根据所选业务,创建业务对象。所以对于我的电话我想做以下事情:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:" + detail.tel]];
但这显然不起作用。谁能告诉我这是怎么做到的?
答案 0 :(得分:1)
我会创建一个[NSString stringWithFormat],然后将其插入“URLWithString”。
-(IBAction)MakePhoneCall:(id)sender
{
NSString *string = [NSString stringWithFormat:@"tel:%@", detail.tel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string];
}
希望有所帮助。
答案 1 :(得分:1)
如果您正在从您的应用程序拨打电话并希望用户在通话结束后返回应用程序,则使用telprompt:而不是tel:如下所示
-(IBAction)MakePhoneCall:(id)sender
{
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:@"telprompt://%@",detail.tel]];
[[UIApplication sharedApplication] openURL:URL];
}