2016-10-05 19 views
0

我正在使用Google Maps iOS SDK作为我正在使用的应用程序。我现在需要在应用程序返回到前台或用户返回到地图视图时重新映射用户当前位置的地图。我搜索并搜索了一些东西,然而,没有任何工作。使用Swift将应用程序返回到前台时的Recenter Google地图

我已经尝试将代码放置在CoreLocation堆栈的“didUpdateLocations”处理程序中,但这不起作用。与此同时,viewWillAppear函数在应用程序返回到前台时不会被调用,所以也不起作用。

func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {   
    let camera = GMSCameraPosition.camera(withLatitude: (manager.location!.coordinate.latitude), longitude: (manager.location!.coordinate.longitude), zoom: 16.0) 
    self.mapView?.animate(to: camera) 
} 

任何帮助表示赞赏。

回答

0

您是否尝试过使用NotificationCenter?将视图控制器中的观察者添加到地图中,然后将通知发布到applicationDidBecomeActive的AppDelegate中。 (由于我的声望,我无法发表任何评论)

相关问题