ios - polylineWithPath :path GMSThreadException 崩溃

标签 ios objective-c google-maps google-directions-api

我正在使用 this绘制路线的源代码在线时崩溃,

 polyline = [GMSPolyline polylineWithPath:path];

Terminating app due to uncaught exception 'GMSThreadException', reason: 'All calls to the Google Maps SDK for iOS must be made from the UI thread'

即使我走了through但对我不起作用。

最佳答案

在闭包中执行UI 更新时,请记住获取主线程并仅在主线程上执行 UI 操作

我的错误是,我试图在 Web 服务完成 block 中绘制标记。

dispatch_async(dispatch_get_main_queue(),
{
    //Your code...
})

关于ios - polylineWithPath :path GMSThreadException 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43515305/

相关文章:

ios - 在另一个 collectionview 的 header 中实现 collectionview 时出错

objective-c - 以编程方式截取特定区域的屏幕截图

ios - 在 iOS 中的 TabBar Controller 上滑动 viewController

javascript - 如何在 google.maps.event.addListener 中使用它

javascript - 如何在特定经纬度加载街景容器,同时点击事件获取街景?

javascript - 为什么当我尝试创建第二个 map 实例时,Google Maps JavaScript API v3 无法正常工作?

ios - WatchKit 扩展崩溃

从 XIB 加载的 iOS UITableView header

c# - Xamarin.Forms 中带有图像的短信

ios - UITableview 从上一个 View 返回时更改 Y 位置