2016-08-06 15 views
2

Ich habe eine EXC_BAD_ACCESS, die mich verrückt machen !! Ich versuche, eine benutzerdefinierte GMSCircle zu erstellen und wenn ich eine Instanz von GMSMapView bin zuweisen, es verursachen Absturz ...EXC_BAD_ACCESS mit GMSMapView

Wer kann mir helfen, ist dies Code:

... 
@property (nonatomic, strong) GMSMapView *mapView; 
@property (nonatomic, strong) PGCRadarCircle *circle; 
... 
_mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera]; 
... 
_circle = [PGCRadarCircle radarWithPosition:[PGCLocationManager instance].currentLocation.coordinate 
               map:_mapView 
               radius:500]; 

und

PGCRadarCircle.h 

... 
@property (nonatomic, strong) GMSMapView* map; 
... 

- (id)initWithPosition:(CLLocationCoordinate2D)coordinate map:(GMSMapView*)mapView radius:(CLLocationDistance)radius { 
    if (self = [super init]) 
    { 
     self.numberOfPulse = 2; 
     self.map = mapView; 
     self.position = coordinate; 
     self.radius = radius; 
     self.fillColor = [UIColor colorWithWhite:1.0 alpha:0.5]; 
     self.strokeColor = [UIColor colorWithWhite:0.9 alpha:0.5]; 
     self.strokeWidth = 1; 
     self.running = false; 
     self.waves = [[NSMutableArray alloc] init]; 
     self.duration = 2; 


     GMSCircle *wave = [GMSCircle circleWithPosition:self.position radius:0]; 
     wave.fillColor = _fillColor; 
     wave.strokeColor = _strokeColor; 
     wave.strokeWidth = _strokeWidth; 
     wave.map = _map; <--- EXC_BAD_ACCESS at this line 

     [_waves addObject:wave]; 

     [self initWaves]; 
    } 

    return self; 
} 

Und ein Screenshot des Stapels:

screenshot

object

Danke.

+0

Sind Sie mit ARC? – Droppy

+0

Hi @Droppy, ja ich benutze Xcode 7 mit ARC. – aliasdoc

+0

OK, bitte posten Sie das komplette Crash-Log oder den Stack-Trace. – Droppy

Antwort

0

Ich hatte das gleiche Problem. Mein EXC_BAD_ACCESS ist verschwunden, nachdem ich den Kreisradius eingerichtet habe, bevor ich Map (GMSMapView) dem GMSCircle zugewiesen habe. Versuchen Sie also, die Zeile self.map = mapView; in Ihrem Code niedriger zu setzen. Ich hoffe es hilft dir!

1

Dieses Problem kann sein, weil Ihre Koordinate ungültig ist, versuchen Sie einen Scheck in sie:

if (CLLocationCoordinate2DIsValid(self.position)) { 
    wave.map = _map; 
}