![](/img/trans.png)
[英]iOS - Make WhatsApp voice/video call programmatically from my application
[英]Make call from iphone application programmatically
我正在开发iphone应用程序,并且带有电话号码标签,我需要通过用户触摸电话号码来拨打电话。 我尝试使用以下代码,但没有打电话,我目前正在使用xcode模拟器进行检查。
我的代码
在我的头文件中
IBOutlet UILabel* lableMakeCall1;
@property(nonatomic,retain) UIView* lableMakeCall1;
我的.m文件包含
- (void)viewDidLoad
{
lableMakeCall1.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture1 = \
[[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(didTapLabelWithGesture1:)];
[lableMakeCall1 addGestureRecognizer:tapGesture1];
}
- (void)didTapLabelWithGesture1:(UITapGestureRecognizer *)tapGesture1 {
NSString *phoneNumber = [@"tel://" stringByAppendingString:lableMakeCall1.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
/*
I tried in this code also
NSString *phoneNumber = [@"telprompt://" stringByAppendingString:lableMakeCall1.text];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];*/
}
您无法在iOS Simulator上拨打电话,因此需要在iPhone上进行测试。 您也无法在iPod Touch和iPad上拨打电话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.