我还没有解决这个问题。
我在几个项目中使用过谷歌地图,包括 Objective C、Swift 2 和 iOS 9。我使用 cocoa pods 安装它,它工作得很好,但现在,在这个应用程序中我也使用 parse和一个四方形的 API(不确定这是否与它有任何关系), map View 甚至无法加载,当我尝试加载时,应用程序崩溃了。
这是我收到的错误...
-[GMSMapView animateToCameraPosition:]:无法识别的选择器发送到实例 0x7fe51cb3bfb0
它在设置 map View 框架的行上中断,我也尝试添加 Obj-C 链接器标志(我听说这可能是一个可能的解决方案),但这本身给了我 32 个不同的错误。
谁能帮忙解决这个问题吗?谢谢一百万。
最佳答案
不能说我有使用 Swift 中的 Google map 的经验,但这里有一些可以使用的 Obj-C 代码。首先确保您的 GMSMapView 委托(delegate)设置为 self 并且您正在 viewDidLoad 中设置约束。我在不同的地方运行过这个:
- (void)setBounds
{
CLLocationCoordinate2D coordinate = [self.currentLocation coordinate];
CGFloat coordinateDifference = 0.002;
CGFloat firstLatitude = coordinate.latitude;
firstLatitude += coordinateDifference;
CGFloat firstLongitude = coordinate.longitude;
firstLongitude += coordinateDifference;
CLLocationDegrees topLat = firstLatitude;
CLLocationDegrees topLon = firstLongitude;
CLLocationCoordinate2D northEastCoordinate = CLLocationCoordinate2DMake(topLat, topLon);
CGFloat secondLatitude = coordinate.latitude;
secondLatitude -= coordinateDifference;
CGFloat secondLongitude = coordinate.longitude;
secondLongitude -= coordinateDifference;
CLLocationDegrees botLat = secondLatitude;
CLLocationDegrees botLon = secondLongitude;
CLLocationCoordinate2D southWestCoordinate = CLLocationCoordinate2DMake(botLat, botLon);
self.bounds = [[GMSCoordinateBounds alloc] init];
self.bounds = [[GMSCoordinateBounds alloc] initWithCoordinate:northEastCoordinate coordinate:southWestCoordinate];
}
- (void)createMap
{
CLLocationCoordinate2D coordinate = [self.currentLocation coordinate];
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:coordinate.latitude longitude:coordinate.longitude zoom:17];
CGFloat h = self.topLayoutGuide.length;
CGRect rect = CGRectMake(0, h, self.view.bounds.size.width, self.view.bounds.size.height - self.navigationController.navigationBar.frame.size.height - self.postSongButton.frame.size.height - 20);
self.mapView = [GMSMapView mapWithFrame:rect camera:camera];
[self.view insertSubview:self.mapView atIndex:0];
}
关于ios - 谷歌地图无法加载,整个应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34752431/