Xcode 8.2 应用程序崩溃 -[viewcontroller .cxx_destruct] 符号化崩溃报告
Xcode 8.2 app Crash -[viewcontroller .cxx_destruct] symbolicated crash report
应用程序出现以下崩溃,无法理解此崩溃背后的原因。这个崩溃报告是我从 App Store 得到的。这是崩溃报告截图
它主要影响 iOS 10.2。在此 class 中,我使用 Google 地图、Pageviewcontroller 和计时器。那么,谁能告诉我怎么弄出来的?
发生此崩溃是由于使用 addObserver forKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew
从 Google 地图获取用户当前位置。
while dealloc Google Maps,那个时候你需要移除这个Observer。否则应用程序将崩溃并出现以下错误
NSInternalInconsistencyException: An instance 0x1759f350 of class GMSMapView was deallocated while key value observers were still registered with it. Current observation info: ( Context: 0x0, Property: 0x177a4490> )
在将 Google 地图添加到 mapView 之前,您需要添加观察者,如下所示:
// Listen to the myLocation property of GMSMapView.
[mapView_ addObserver:self
forKeyPath:@"myLocation"
options:NSKeyValueObservingOptionNew
context:NULL];
self.view = mapView_;
// Ask for My Location data after the map has already been added to the UI.
dispatch_async(dispatch_get_main_queue(), ^{
mapView_.myLocationEnabled = YES;
});
#pragma mark - KVO updates
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if (!firstLocationUpdate_) {
// If the first location update has not yet been received, then jump to that
// location.
firstLocationUpdate_ = YES;
CLLocation *location = [change objectForKey:NSKeyValueChangeNewKey];
mapView_.camera = [GMSCameraPosition cameraWithTarget:location.coordinate
zoom:14];
}
}
然后添加此代码也用于删除观察者
- (void)dealloc {
[mapView_ removeObserver:self
forKeyPath:@"myLocation"
context:NULL];
}
更多详情:Google Maps iOS SDK, Getting Current Location of user
应用程序出现以下崩溃,无法理解此崩溃背后的原因。这个崩溃报告是我从 App Store 得到的。这是崩溃报告截图
它主要影响 iOS 10.2。在此 class 中,我使用 Google 地图、Pageviewcontroller 和计时器。那么,谁能告诉我怎么弄出来的?
发生此崩溃是由于使用 addObserver forKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew
从 Google 地图获取用户当前位置。
while dealloc Google Maps,那个时候你需要移除这个Observer。否则应用程序将崩溃并出现以下错误
NSInternalInconsistencyException: An instance 0x1759f350 of class GMSMapView was deallocated while key value observers were still registered with it. Current observation info: ( Context: 0x0, Property: 0x177a4490> )
在将 Google 地图添加到 mapView 之前,您需要添加观察者,如下所示:
// Listen to the myLocation property of GMSMapView.
[mapView_ addObserver:self
forKeyPath:@"myLocation"
options:NSKeyValueObservingOptionNew
context:NULL];
self.view = mapView_;
// Ask for My Location data after the map has already been added to the UI.
dispatch_async(dispatch_get_main_queue(), ^{
mapView_.myLocationEnabled = YES;
});
#pragma mark - KVO updates
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
if (!firstLocationUpdate_) {
// If the first location update has not yet been received, then jump to that
// location.
firstLocationUpdate_ = YES;
CLLocation *location = [change objectForKey:NSKeyValueChangeNewKey];
mapView_.camera = [GMSCameraPosition cameraWithTarget:location.coordinate
zoom:14];
}
}
然后添加此代码也用于删除观察者
- (void)dealloc {
[mapView_ removeObserver:self
forKeyPath:@"myLocation"
context:NULL];
}
更多详情:Google Maps iOS SDK, Getting Current Location of user