ios - iOS,GMSMapView,MapView:didTapMarker 应用程序崩溃
问题描述
当用户点击标记(GMSMapVIew:didTapMarker)时,我的应用程序崩溃了,而 myApp 在 99% 的情况下运行良好,但有时它会在 crashlytics 上显示崩溃。它是如此随机发生的。
崩溃报告显示以下内容。
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000002f6ce97f4
-[BadgerMapView mapView:didTapMarker:]
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x1f025653c objc_msgSend + 28
1 Badger 0x104d3af84 -[BadgerMapView mapView:didTapMarker:] + 1784 (BadgerMapView.m:1784)
2 CoreFoundation 0x1f106b900 __invoking___ + 144
3 CoreFoundation 0x1f0f4d4d0 -[NSInvocation invoke] + 292
4 CoreFoundation 0x1f0f4e104 -[NSInvocation invokeWithTarget:] + 60
5 Badger 0x104e940e0 -[GMSDelegateForward forwardInvocation:] + 4339744992
6 CoreFoundation 0x1f10697c0 ___forwarding___ + 636
7 CoreFoundation 0x1f106b75c _CF_forwarding_prep_0 + 92
8 Badger 0x104ea01fc -[GMSMapView didTapMarker:] + 20436
9 Badger 0x104eb8a88 -[GMSMarker wasTapped] + 120928
10 UIKitCore 0x21d1c3868 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] + 64
11 UIKitCore 0x21d1cba70 _UIGestureRecognizerSendTargetActions + 124
12 UIKitCore 0x21d1c9414 _UIGestureRecognizerSendActions + 316
13 UIKitCore 0x21d1c8940 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 760
14 UIKitCore 0x21d1bca1c _UIGestureEnvironmentUpdate + 2180
15 CoreFoundation 0x1f0ff55f8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
16 CoreFoundation 0x1f0ff0320 __CFRunLoopDoObservers + 412
17 CoreFoundation 0x1f0ff089c __CFRunLoopRun + 1228
18 CoreFoundation 0x1f0ff00b0 CFRunLoopRunSpecific + 436
19 GraphicsServices 0x1f31f079c GSEventRunModal + 104
20 UIKitCore 0x21d59a978 UIApplicationMain + 212
21 Badger 0x104cb863c main + 17 (main.m:17)
22 libdyld.dylib 0x1f0ab58e0 start + 4
下面是我的应用程序崩溃的代码。
獾地图视图.m:1784
if (![waypt isKindOfClass:[NSNull 类]])
This is the line where i got crash
- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker
{
CLLocationCoordinate2D markerLocation = marker.position;
double tappedMarkerLattitude = markerLocation.latitude;
double tappedMarkerLongitude = markerLocation.longitude;
NSArray *waypoints =[MapViewController sharedInstance].wayPointsToShowOnRouteMode;
for (PlannerWaypoint *waypt in waypoints)
{
@try {
if (![waypt isKindOfClass:[NSNull class]]) {
if (![waypt isEqual:nil]) {
[MapViewController sharedInstance].currentWaypoint = waypt;
NSNumber *nextWayPointIndex = [MapViewController sharedInstance].currentWaypoint.modPosition;
NSNumber *prevWayPointIndex = [MapViewController sharedInstance].currentWaypoint.modPosition;
int value = [nextWayPointIndex intValue];
nextWayPointIndex = [NSNumber numberWithInt:value + 1];
NSUInteger nextWayPointIndexInt = [nextWayPointIndex integerValue];
prevWayPointIndex = [NSNumber numberWithInt:value - 1];
NSUInteger prevWayPointIndexInt = [prevWayPointIndex integerValue];
int waypointCount = (int)[waypoints count];
if (nextWayPointIndexInt > (waypointCount-1)) {
[MapViewController sharedInstance].nextWaypoint = [waypoints objectAtIndex:0];
}
else {
[MapViewController sharedInstance].nextWaypoint = [waypoints objectAtIndex:nextWayPointIndexInt];
}
if (prevWayPointIndexInt > (waypointCount-1)) {
[MapViewController sharedInstance].previousWaypoint = [waypoints objectAtIndex:(waypointCount-1)];
}
else {
[MapViewController sharedInstance].previousWaypoint = [waypoints objectAtIndex:prevWayPointIndexInt];
}
if([Utility isIphone] == NO) {
[[MapViewController sharedInstance] showMarkerSelectedAtMiddle:[MapViewController sharedInstance].currentWaypoint];
UIViewController *viewcontroller = [MenuViewController sharedInstance].presentedViewController;
if([viewcontroller.childViewControllers objectAtIndex:0]!=nil) {
RouteModeViewController *routeModeView = [viewcontroller.childViewControllers objectAtIndex:0];
[routeModeView.customerCardNameLabel setText:[MapViewController sharedInstance].waypointLabel];
}
} else {
UINavigationController *UINavController = (UINavigationController *)self.window.rootViewController.presentedViewController;
UIViewController *UIViewCon = [[UINavController viewControllers] lastObject];
if ([UIViewCon isKindOfClass:[MapViewController class]]) {
MapViewController *mapViewController = (MapViewController *)UIViewCon;
[mapViewController showMarkerSelectedAtMiddle:waypt];
}
}
[waypt release];
waypt = nil;
break;
}
}
} @catch (NSException *exception) {
NSLog(@"Exception in ProcessdidTapMarker: %@",exception);
[DeviceLoger log:[NSString stringWithFormat:@"Exception in ProcessdidTapMarker: %@",exception]];
}
}
return YES;
}
有人有想法吗?
请帮助我,因为我面临这个问题很长时间了
谢谢!
解决方案
推荐阅读
- python - 如何在Python中对具有字符串作为键和整数作为值的字典进行排序
- c++ - 了解在 STL 映射中使用的运算符重载“const”语法
- python - PyCaret NLP assign_model(lda) 在空行上分配主题
- javascript - 如何使用 SelectAreas.js 设置图像上边界框的数量限制
- c# - ASP.NET Core 代码优先中的迁移不起作用
- python - 美丽的汤选择器
- docker - 纱线安装错误“ENOENT:没有这样的文件或目录
- slack-api - Slack API - 为某些帖子生成:invalid_arg_name
- r - 上传 2 个文件时的条件面板
- flutter - 在 Flutter Grid 视图中制作 Sticky 左侧标题视图