方案一:親測能夠async
if (_telPhone.length == 0) { return; } NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", _telPhone]; CGFloat version = [[[UIDevice currentDevice]systemVersion]floatValue]; if (version >= 10.0) { /// 大於等於10.0系統使用此openURL方法 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone] options:@{} completionHandler:nil]; } else { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]]; }
方案二:寫個線程,有說iOS 11不起做用,因爲沒有真機,未測試測試
if (_telPhone.length == 0) { return; } NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", _telPhone]; dispatch_async(dispatch_get_global_queue(0, 0), ^{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]]; });