我已经写了下面的代码来打电话,按下呼叫按钮后,需要9-10秒才能打开拨号屏幕。
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",phoneURLString]];
[[UIApplication sharedApplication] openURL:url];有没有其他打电话的方法?或者,我如何减少打开拨号屏幕所需的时间?
发布于 2015-06-03 17:21:09
这看起来像是线程问题。这段代码是从主线程调用的吗?如果不是,那么这就是一个问题: UIKit不是线程安全的,所以您必须从主线程执行所有操作:
NSString *phoneURLString = [NSString stringWithFormat:@"tel:%@", phoneNumber];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",phoneURLString]];
dispatch_async(dispatch_get_main_queue(), ^{
[[UIApplication sharedApplication] openURL:url];
});https://stackoverflow.com/questions/30615521
复制相似问题