在回调中调用系统拨打电话的方法无效

残日尽头 2016-11-08 05:35:56
NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:[@"如果收不到验证码,请致电:" stringByAppendingString:kTelephone]];

content.font = [UIFont systemFontOfSize:14.f];

[content setTextHighlightRange:NSMakeRange(13, content.string.length - 13)
color:UIColorHex(0x4286FF)
backgroundColor:UIColorHex(0x606060)
tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
UIWebView *webView = [[UIWebView alloc]init];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",@"110"]];
[webView loadRequest:[NSURLRequest requestWithURL:url ]];
[self.view addSubview:webView];
}];


代码如上。没有任何反应 在毁掉中加了dispatch保证在主线程调用,也没用。
...全文
397 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:[@"如果收不到验证码,请致电:" stringByAppendingString:kTelephone]];
     
    content.font = [UIFont systemFontOfSize:14.f];
     
    [content setTextHighlightRange:NSMakeRange(13, content.string.length - 13)
                             color:UIColorHex(0x4286FF)
                   backgroundColor:UIColorHex(0x606060)
                         tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
                            NSURL *url=[NSURL URLWithString:@"telprompt://10086"];
                           [[UIApplication sharedApplication]openURL:url];
                         }];
Army_Ma 2017-02-28
  • 打赏
  • 举报
回复
[[UIApplication sharedApplication] openURL:[NSURLURLWithString:@"tel://8008808888"]];
 打电话:建议用telprompt://而不用tel://,因为前者有拨打前提示,且拨打完成后回到原先应用界面。 NSURL *url=[NSURL URLWithString:@"telprompt://10086"]; [[UIApplication sharedApplication]openURL:url];
javaoraspx 2016-11-10
  • 打赏
  • 举报
回复
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"tel:%@",phone]]; if([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }
残日尽头 2016-11-08
  • 打赏
  • 举报
回复
帮顶~~~~ 求指点

29,028

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧