我的应用程序有初始搜索屏幕并且在搜索中转到导航中的地图屏幕(GMSMapView
),在多个来回转换应用程序崩溃后没有错误,有时出现错误
*由于未捕获的异常'NSInternalInconsistencyException'而终止应用,原因:'{id:31684}: -observeValueForKeyPath:ofObject:change:context:收到消息但未处理。 关键路径:相机 观察对象:; layer => 变化:{ kind = 1; new =“GMSCameraPosition 0x149091040:target:(51.179,-1.826)bearing:0.000 zoomLevel:4.000 viewingAngle:0.000”; } 上下文:0x0' * 第一次抛出调用堆栈: (0x183326d8c 0x1824e05ec 0x183326c6c 0x183d39e5c 0x183cb52f8 0x183cb4e30 0x183d39ca0 0x101296d34 0x101294fbc 0x101293fe0 0x18d569edc 0x18d6cb628 0x18d6cb360 0x18d569b84 0x18d6cb628 0x18d6cb7a0 0x18d6cb360 0x18d568ed4 0x18d39aadc 0x18cfde0f0 0x18cf02b90 0x18cf02acc 0x18d2403b4 0x18cfafac8 0x18cfaf720 0x18cfa3424 0x18cefb770 0x18749d25c 0x1874a13ec 0x18740daa0 0x1874355d0 0x187436450 0x1832ce910 0x1832cc238 0x1832cc884 0x1831ecda8 0x1851cf020 0x18d1cd78c 0x100d953a8 0x182c7dfc0) libc ++ abi.dylib:以NSException类型的未捕获异常终止
这是我的mapView屏幕代码
func createMap()
{
mapView.delegate = self
mapView.isMyLocationEnabled = true
mapView.settings.scrollGestures = true
mapView.settings.zoomGestures = true
mapView.settings.compassButton = true
mapView.padding = UIEdgeInsetsMake (0,0,0,0)
mapView.settings.myLocationButton = true
mapView.isHidden = true
}
以下viewWillDisappear
屏幕中的mapview
代码
override func viewWillDisappear(_ animated: Bool)
{
super.viewDidDisappear(true)
// Remove Advertisemnt
appDelegate.removeAdsFromViewController(controller: self)
NotificationCenter.default.removeObserver(self)
self.clusterManager.clearItems()
self.mapView.clear()
}