美文网首页iOS Development
iOS开发笔记-36: 调起拨打电话窗口有延迟

iOS开发笔记-36: 调起拨打电话窗口有延迟

作者: 原味蛋炒饭 | 来源:发表于2017-05-17 15:13 被阅读5次
                    //方法1
                    NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", _kServicePhone];
                    dispatch_async(dispatch_get_global_queue(0, 0), ^{
                        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
                    });
                    
                    //方法2
                    NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", _kServicePhone];
                    NSComparisonResult compare = [[UIDevice currentDevice].systemVersion compare:@"10.0"];
                    if (compare == NSOrderedDescending || compare == NSOrderedSame) {
                        /// 大于等于10.0系统使用此openURL方法
                        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil];
                    } else {
                        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
                    }


从上述方法可以看出,问题在于ios10之后,openURL阻塞主线程

相关文章

网友评论

    本文标题:iOS开发笔记-36: 调起拨打电话窗口有延迟

    本文链接:https://www.haomeiwen.com/subject/ozudxxtx.html