iOS使用UIAlertController拨打电话

iOS拨打电话

NSMutableString *str=[[NSMutableString alloc]initWithFormat:@"18514697034"];
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                             message:str
                                                                      preferredStyle:UIAlertControllerStyleAlert];
                          
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消"
                                                           style:UIAlertActionStyleCancel
                                                         handler:^(UIAlertAction *action) {
        
    }];
                          
    UIAlertAction *otherAction = [UIAlertAction actionWithTitle:@"拨打"
                                                          style:UIAlertActionStyleDefault
                                                        handler:^(UIAlertAction *action) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
    }];
                          
                          // Add the actions.
    [alertController addAction:cancelAction];
    [alertController addAction:otherAction];
    [self presentViewController:alertController
                       animated:YES completion:nil];

这种方法应该是体验比较好的一种,比较流畅

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 片刻后,已自封为丞相的侯景正穿过一条宽广的长廊,尽头便是皇宫的正殿太极殿,殿外都用锦石白玉铺垫,侯景虽长相俊秀,但...
    旧文字阅读 4,075评论 0 1
  • 记得在我十几岁的时候,我时常会想,我活在这个地球上,但地球好大,我很小。但之于宇宙,地球很小,我更小,我和生存在这...
    妻妻阅读 3,325评论 0 3
  • 好久都没有更新了,久到我快要我忘了原来我还有个账号在这呢。 清明节学校放假5天,给了自己两天时间,去青岛玩了两天。...
    刘梨阅读 2,481评论 0 0
  • 兼职很累。 想找个和自己专业兴趣有关的兼职,当我去尝试的时候,觉得梦想这东西在现实生活中不存在。...
    后海艺station阅读 2,256评论 0 5
  • 有幸聆听了国防科大老松扬教授关于《网络信息时代基于量子理论的科学思维与世界观升级》讲座后,算是比较系统地接...
    始终在路上阅读 3,599评论 5 19