问题描述
我试图运行基本的iOS演示SDK代码。我已经创建了API密钥,并且它可以正常加载。尽管我已经将代码从viewDidLoad转移到loadView,但效果依然存在。请参阅以下代码:
- (void)loadView {
//创建一个GMSCameraPosition,告诉地图显示
//坐标-33.86,151.20在缩放级别6.
GMSCameraPosition * camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
_mapView.myLocationEnabled = YES;
self.view = _mapView;
//在地图的中心创建一个标记。
GMSMarker * marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86,151.20);
marker.title = @悉尼;
marker.snippet = @澳大利亚;
marker.map = _mapView;
$ / code>
相机已创建,但执行此行时
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
使用描述抛出NSException - > - [GMSMapView animateToCameraPosition:]:发送给实例的无法识别的选择器。
$ b
< / blockquote>
< p>不分配它。
我很幸运地设法让它工作。谷歌地图上的谷歌文档声明如下:
但是他们的示例项目考试,有标志设定目标。在我的项目中将其设置在我的项目中的构建目标上会有所帮助,并且我发布的代码也能正常工作。
Im trying to run the basic iOS demo SDK code. I have created the API keyand it loads ok.Although i've transfered the code from viewDidLoad to loadView the effect remains. See the following code
-(void)loadView{
// Create a GMSCameraPosition that tells the map to display the
// coordinate -33.86,151.20 at zoom level 6.
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
longitude:151.20
zoom:6];
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
_mapView.myLocationEnabled = YES;
self.view = _mapView;
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
marker.title = @"Sydney";
marker.snippet = @"Australia";
marker.map = _mapView;
}
The camera is created but when this line is executed
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
an NSException is thrown with the description -> -[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance.
I don't assign that delegate as well as Googles Base Code does not assign it.I have fortunetly managed to get it working. The google documentation on Google Maps states what follows:
But their example project, after my examination, has the flag set on target. Setting it on the build target within my project in my case helped and my posted code works fine.
这篇关于GoogleMaps基本iOS演示应用崩溃 - 发送给实例的无法识别的选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!