def*_*fou 1 iphone google-maps ios uistoryboardsegue
我在我的应用程序中做的是:
我将一些数据加载到核心数据中,当完成时,应用程序需要转到下一个视图(谷歌地图)
[self performSegueWithIdentifier:@"loadMap" sender:self];
但是我得到了这个错误
Terminating app due to uncaught exception 'GMSThreadException', reason: 'All calls to the Google Maps SDK for iOS must be made from the UI thread'
如果我做所有这一切,但通过点击按钮做一个segue一切正常.
storyboard中的Google地图视图控制器有一个带有初始化代码的GMSMapView视图插座
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:45.331875
longitude:14.450455
zoom:14];
self.mapView.camera = camera;
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = camera.target;
marker.title = @"Test title";
marker.snippet = @"Lorem ipsum...";
marker.map = self.mapView;
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?如何使用故事板以编程方式加载谷歌地图的视图控制器?
Kam*_*ros 10
异常似乎表明您正在尝试在后台线程中执行segue.要阻止它崩溃,您需要使用主线程.performSegueWithIdentifier:sender:使用主线程包装如下:
dispatch_async(dispatch_get_main_queue(), ^{
[self performSegueWithIdentifier:@"loadMap" sender:self];
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2565 次 |
| 最近记录: |