Je suis en train de déplacer mon application vers IOS 7 .
J'ai une carte et sur cette carte je dessine MKPolyLine
.
Tout a fonctionné jusqu'à ce que l'application IOS 7 tombe en panne.
J'ai changé viewForOverLay
avec une nouvelle méthode:
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay { if ([overlay isKindOfClass:[MKPolyline class]]) { MKPolyline *route = overlay; MKPolylineRenderer *routeRenderer = [[MKPolylineRenderer alloc] initWithPolyline:route]; routeRenderer.strokeColor = [UIColor redColor]; routeRenderer.lineWidth = 7; return routeRenderer; } else return nil; }
Dans ViewDidLoad, j'appelle:
[self performSelectorInBackground:@selector(drawPathInBackground) withObject:nil];
Et voici la mise en œuvre:
-(void)drawPathInBackground{ for(int idx = 0; idx < [routes count]; idx++) { Path *m_p = [routes objectAtIndex:idx]; CLLocationCoordinate2D workingCoordinate; workingCoordinate.latitude=m_p.Latitude; workingCoordinate.longitude=m_p.Longitude; MKMapPoint point = MKMapPointForCoordinate(workingCoordinate); pointArr[idx] = point; } self.routeLine = [MKPolyline polylineWithPoints:pointArr count:[routes count]]; //[self.mapView addOverlay:self.routeLine]; //free(pointArr); dispatch_async(dispatch_get_main_queue(), ^{ [self.mapView addOverlay:self.routeLine]; free(pointArr); }); }
Sur cette ligne: [self.mapView addOverlay:self.routeLine];
Je reçois: EXC_BAD_ACCESS (code = 2, adresse = 0x0)
Vous n'êtes pas censé effectuer des opérations d'interface user sur un thread d'arrière-plan. UI sur le fil principal seulement.