我有一个EXC_BAD_ACCESS,他让我发疯!我正在尝试创建自定义GMSCircle,并在分配GMSMapView实例时导致崩溃...
任何人都可以帮助我,这是代码:
...
@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];
和
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;
}
和堆栈的屏幕截图:
screenshot
object
谢谢。
最佳答案
此问题可能是因为您的坐标无效,请尝试检查一下它:
if (CLLocationCoordinate2DIsValid(self.position)) {
wave.map = _map;
}
关于ios - EXC_BAD_ACCESS与GMSMapView,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38805660/