[UIView setMyLocationEnabled:]:无法识别的选择器发送到实例0x14d9d3c0

时间:2016-07-29 13:07:15

标签: ios objective-c google-maps

尝试将GMSMapView插入我的应用程序我所做的一切,包括插入googlemap框架和创建api密钥,但每当我运行时出现此异常。请帮我解决。

这是我的代码。

- (void)viewDidLoad {
    [super viewDidLoad];
    self.mapView.myLocationEnabled = YES;

    self.mapView.mapType = kGMSTypeNormal;

    self.mapView.settings.compassButton = YES;

    self.mapView.settings.myLocationButton = YES;

    self.mapView.delegate = self;
}
  

[UIView setMyLocationEnabled:]:无法识别的选择器发送到实例0x14d9d3c0

1 个答案:

答案 0 :(得分:0)

请检查如下:

- (void)viewDidLoad   
{
  [super viewDidLoad];
  if ([self.mapView isKindOfClass:[GMSMapView class]]) {
    self.mapView.myLocationEnabled = YES;

    self.mapView.mapType = kGMSTypeNormal;

    self.mapView.settings.compassButton = YES;

    self.mapView.settings.myLocationButton = YES;

    self.mapView.delegate = self;
  }else
  {
    NSLog(@"Make sure your object is GMSMapView because its not!!");
  }  
}