初始化时GMSMapView失败 - 尝试从对象[0]

时间:2016-06-10 14:13:07

标签: objective-c google-maps google-maps-sdk-ios

我尝试使用带有Objetive -c的iOS SKD初始化Google地图时遇到此错误,并执行文档https://developers.google.com/maps/documentation/ios-sdk/中的代码。

2016-06-10 08:42:24.585 XXXXXApp[11103:451806] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010b33ed85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010adb2deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010b23b23e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
    3   CoreFoundation                      0x000000010b24d5bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    4   UIKit                               0x00000001094ff287 -[UIButton _intrinsicSizeWithinSize:] + 1478
    5   UIKit                               0x00000001091f11ad -[UIView(Geometry) sizeToFit] + 253
    6   XXXXXApp                            0x0000000105c23ba0 -[GMSUISettingsView init] + 425
    7   XXXXXApp                            0x0000000105bab236 -[GMSUISettings initWithMapView:vectorMapView:] + 222
    8   XXXXXApp                            0x0000000105b9b053 -[GMSMapView sharedInitWithServices:camera:forPlaces:] + 1930
    9   XXXXXApp                            0x0000000105b99fdc -[GMSMapView initWithFrame:camera:] + 124
    10  XXXXXApp                            0x0000000105b99e01 +[GMSMapView mapWithFrame:camera:] + 104

该行:[GMSMapView mapWithFrame:CGRectZero camera:camera] 是所有失败的地方。

- (void)viewDidLoad {
      [super viewDidLoad];
      GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
                                                              longitude:151.2086
                                                                   zoom:6];
      GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

      GMSMarker *marker = [[GMSMarker alloc] init];
      marker.position = camera.target;
      marker.snippet = @"Hello World";
      marker.appearAnimation = kGMSMarkerAnimationPop;
      marker.map = mapView;

      self.view = mapView;
}

我在--loadView--方法中尝试了这个代码,问题仍然存在。

0 个答案:

没有答案
相关问题