Cet accident se produit en raison d'aller chercher l'emplacement actuel de l'utilisateur de Google Maps à l'aide addObserverforKeyPath:@"myLocation" options:NSKeyValueObservingOptionNew
.
Alors que dealloc Google Maps, cette fois vous devez supprimer cet observateur. Sinon, l'application se bloque avec l'erreur suivante
NSInternalInconsistencyException: Une instance 0x1759f350 de classe GMSMapView a été désallouée tandis que les observateurs de valeur clés étaient encore enregistrées avec elle. Information d'observation actuelle: (Contexte: 0x0, propriété: 0x177a4490>)
vous devez addObserver avant d'ajouter Google Maps à Mapview comme suit:
// 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];
}
}
puis ajoutez ce code aussi pour enlever l'observateur
- (void)dealloc {
[mapView_ removeObserver:self
forKeyPath:@"myLocation"
context:NULL];
}
pour plus de détails: Google Maps iOS SDK, Getting Current Location of user
vous plait exceptionnels Points de rupture – ajjjjjjjj
Ce rapport de crash je l'ai eu de App Store. Pendant le test/débogage, je ne reçois pas ce problème/crash. –
@AntonyRaphel Demandez-leur de fournir des étapes à reproduire car vous ne pouvez pas, ils vont aider, ou ils doivent avoir donné des mesures pour reproduire vérifier leur réponse attentivement. – iphonic