5

我正在尝试将地图添加到我的自定义键盘扩展中。在我尝试在键盘中添加 MKMapView 后,当地图视图出现时,我立即崩溃。所以我正在尝试将谷歌地图添加到键盘。但不走运,我收到错误:

Terminating app due to uncaught exception 'GMSBackgroundAppException', reason: 'Background execution would crash in this scenario'

我从谷歌地图文档中复制了确切的代码,然后在另一个空白项目中运行了这段代码,并且成功了。但它在自定义键盘扩展中不起作用。它给了我上面的错误。如果你还想看下面的代码:

- (void)viewDidLoad {
    [super viewDidLoad];

    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_;
}
4

0 回答 0