/*、
此处提供的方法是简单的、快速的。
用下面的方法发送短信和邮件后,不会自动跳回到app
*/
#pragma mark - 按钮的点击事件
- (void)buttonClicked:(UIButton *)sender{
if (sender.tag ==1) {//打电话
NSString *telNumber = @"182xxxxxxxx";
NSString *urlString = [NSStringstringWithFormat:@"telprompt://%@",telNumber];//提示用户确认是否拨打电话
[selfopenUrl: urlString];
}elseif (sender.tag ==2){//发送短信
NSString *telNumber = @"182xxxxxxxx";
NSString *urlString = [NSStringstringWithFormat:@"sms://%@",telNumber];
[selfopenUrl: urlString];
}elseif (sender.tag ==3){//发邮件
NSString *mailAddress = @"182xxxxxxxx@163.com";
NSString *url = [NSStringstringWithFormat:@"mailto://%@",mailAddress];
[selfopenUrl:url];
}else{//浏览网页
NSString *url = @"http://blog.csdn.net/wwc455634698/";
[selfopenUrl:url];
}
}
#pragma mark - 打开链接
-(void)openUrl:(NSString *)urlString{
NSURL *url = [NSURLURLWithString:urlString];
UIApplication *application = [UIApplicationsharedApplication];
if([applicationcanOpenURL:url]){
[[UIApplicationsharedApplication] openURL:url options:@{}completionHandler:nil];
}else{
return;
}
}