[英]EXC_BAD_ACCESS with GMSMapView
I have an EXC_BAD_ACCESS who drive me crazy !! 我有一个让我疯狂的EXC_BAD_ACCESS !! I'm trying to create a custom GMSCircle and when I'm assign an instance of GMSMapView, it cause crash...
我正在尝试创建一个自定义GMSCircle,当我分配一个GMSMapView实例时,它会导致崩溃......
Anyone can help me, this is 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];
and 和
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;
}
And a screenshot of stack: 和栈的截图:
Thanks. 谢谢。
This issue can be because your coordinate is invalid, try put a check in it: 这个问题可能是因为您的坐标无效,请尝试检查一下:
if (CLLocationCoordinate2DIsValid(self.position)) {
wave.map = _map;
}
I had the same issue. 我遇到过同样的问题。 My EXC_BAD_ACCESS dissapeared after i set up circle radius before assigning map (GMSMapView) to GMSCircle.
在将地图(GMSMapView)分配给GMSCircle之前设置圆半径后,我的EXC_BAD_ACCESS消失了。 So try to put line
self.map = mapView;
所以尽量把行放在
self.map = mapView;
lower in your code. 你的代码更低。 I hope it will help you!
我希望它会对你有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.