GoogleMaps基本的iOS演示应用程序崩溃 – 无法识别的选择器发送到实例

前端之家收集整理的这篇文章主要介绍了GoogleMaps基本的iOS演示应用程序崩溃 – 无法识别的选择器发送到实例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图运行基本的iOS演示SDK代码.我已经创建了API密钥,它加载好了.
虽然我已将代码从viewDidLoad转移到loadView,但效果仍然存在.请参阅以下代码
-(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;
}

相机已创建,但执行该行时

_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

抛出一个NSException的描述 – > – [GMSMapView animateToCameraPosition:]:无法识别的选择器发送到实例.

* Terminating app due to uncaught exception ‘NSInvalidArgumentException’,reason: ‘-[GMSMapView
animateToCameraPosition:]: unrecognized selector sent to instance
0x14dbb870’
*
First throw call stack: (0x2f462f4b 0x39cd96af 0x2f4668e7 0x2f4651cb 0x2f3b44d8 0x4cebe9 0x4cd78f 0x4ccc41 0x4ccb3d 0x21ced5
0x31bda1bd 0x31bda139 0x1d4b27 0x1d4a83 0x1d51cd 0x31bda37b 0x31c850f1
0x31c85007 0x31c845e3 0x31c8430d 0x31c8407d 0x31c84015 0x31bd5da3
0x3185cc6b 0x3185847b 0x3185830d 0x31857d1f 0x31857b2f 0x31bce0c3
0x2f42e1cd 0x2f42bb71 0x2f42beb3 0x2f396c27 0x2f396a0b 0x34097283
0x31c3a049 0xf58b1 0x3a1e1ab7) libc++abi.dylib: terminating with
uncaught exception of type NSException

解决方法

I think you may have forgotten to make the class a GMSMapView delegate. The GMSMapViewDelegate bit after the () needs to be between <>

我不分配那个委托以及谷歌基本代码不分配它.
我有幸成功地运作. Google Maps上的Google文档说明如下:

Choose your project,rather than a specific target,and open the Build Settings tab.
In the Other Linker Flags section,add -ObjC. If these settings are not visible,change the filter in the Build Settings bar from Basic to All.

但他们的例子项目,经过我的考察,已经设定了目标.将我的项目中的构建目标设置在我的情况下帮助,我的贴子代码工作正常.

原文链接:https://www.f2er.com/iOS/329491.html

猜你在找的iOS相关文章