GoogleMaps basic iOS demo app crash - unrecognized selector sent to instance

前端 未结 9 1822
野趣味
野趣味 2020-11-30 12:45

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.

9条回答
  •  爱一瞬间的悲伤
    2020-11-30 13:27

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

    @interface StructuredGeocoderViewController () GMSMapViewDelegate
    
    @end
    
    @implementation StructuredGeocoderViewController {
      GMSMapView *_mapView;
      GMSGeocoder *_geocoder;
    }
    
    - (void)viewDidLoad {
      [super viewDidLoad];
      GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.868
                                                              longitude:151.2086
                                                                   zoom:12];
    
      _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
      _mapView.delegate = self;
    
      _geocoder = [[GMSGeocoder alloc] init];
    
      self.view = _mapView;
    }
    

提交回复
热议问题