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

                    //方法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: 调起拨打电话窗口有延迟)