我对 iOS 开发人员相对较新,并且对使用 Google Maps API 完全陌生。
我有两个单独的视图,我想要一个地图视图。第一个是允许您在地图上查找位置、输入地址或使用当前位置的场景。在下一个场景中,我想使用与用户从上一个场景输入的位置相同的位置,但我想使用卫星视图而不是常规地图,并且会有一些额外的工具来操作地图以达到目的我的应用程序。
我需要有两个独立的场景,因为界面非常不同,但是我无法将信息从一个地图视图发送到另一个。这是我尝试过的一些方法(其中两个被注释掉了):
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showServiceArea"]) {
ServiceAreaViewController *destViewController = segue.destinationViewController;
destViewController.camera = [GMSCameraPosition cameraWithLatitude:curLocation.location.coordinate.latitude longitude:curLocation.location.coordinate.longitude zoom:17]; //Setting up a camera in the next scene using the curLocation coordinates from the current view
//destViewController.view = _mapView; //Setting the next view controller's view to the current mapView and changing the mapType to satellite
//_mapView.mapType = kGMSTypeSatellite;
//destViewController.serviceAreaMapView = _mapView; //copying the current mapview to a mapview on the next scene
//destViewController.serviceAreaMapView.mapType = kGMSTypeSatellite;
}
}
我尝试过的每种方法都引发了异常并导致我的应用程序崩溃。这是上述代码崩溃的输出:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIViewController setCamera:]:无法识别的选择器发送到实例 0x17e73eb0”
对于前两个注释掉的方法,我认为在加载下一个场景时,我分配给下一个视图的数据正在被删除。我不确定我当前的代码有什么问题。
谁能指出我正确的方向,以便使用当前场景的数据在下一个场景中生成 mapView?谢谢。