Ios 谷歌地图赢得';无法加载,会使整个应用程序崩溃

Ios 谷歌地图赢得';无法加载,会使整个应用程序崩溃,ios,swift,google-maps,Ios,Swift,Google Maps,我还没有解决这个问题 我在一些项目中使用过谷歌地图,包括Objective C、Swift 2和iOS 9。我使用cocoa pods安装它,它运行得很好,但现在,在这个应用程序中,我还使用了解析和一个四方API(不确定这是否与它有关),地图视图甚至不会加载,当我尝试加载时,应用程序崩溃 这是我得到的错误 -[GMSMapView animateToCameraPosition:]:发送到实例0x7fe51cb3bfb0的选择器无法识别 它在设置地图视图框的线路上中断,我也尝试添加Obj-C链接

我还没有解决这个问题

我在一些项目中使用过谷歌地图,包括Objective C、Swift 2和iOS 9。我使用cocoa pods安装它,它运行得很好,但现在,在这个应用程序中,我还使用了解析和一个四方API(不确定这是否与它有关),地图视图甚至不会加载,当我尝试加载时,应用程序崩溃

这是我得到的错误

-[GMSMapView animateToCameraPosition:]:发送到实例0x7fe51cb3bfb0的选择器无法识别

它在设置地图视图框的线路上中断,我也尝试添加Obj-C链接器标志(我听说这可能是一个可能的解决方案),但这本身就给了我32个不同的错误


有人能帮忙吗?非常感谢。

我不能说我有在Swift中使用谷歌地图的经验,但这里有一些Obj-C代码可以使用。首先确保您的GMSMapView委托设置为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];
}