2015-03-19 3 views
0

У меня случайный сбой при выборе маркера на карте. Маркеры, как вы можете видеть в коде, являются обычаями, а когда они отображаются, значок значка скрыт и размещается пользовательский информационный вид. Все методы делегата выполняются обычно каждый раз, так что авария не непосредственно в моем коде, но я мог бы сделать что-то, чтобы «расстроить» Google MapsОшибка Google-Maps-iOS-SDK при выборе маркера

0 libsystem_kernel.dylib   0x000000019a8f9cc8 __kill + 8 
1 libsystem_platform.dylib  0x000000019a977b18 _sigtramp + 68 
2 QuartzCore      0x0000000190908038 -[CALayer _renderBorderInContext:] + 112 
3 QuartzCore      0x0000000190906b64 -[CALayer renderInContext:] + 1032 
4 SP        0x000000010036abf4 -[GMSMapView setSelectedMarker:] + 196 
5 SP        0x000000010036befc -[GMSMapView didTapMarker:] + 112 
6 SP        0x0000000100381830 -[GMSMarker wasTapped] + 60 
7 SP        0x000000010028fa14 -[GMSVectorMapView didTapAt:] + 1252 
8 UIKit       0x0000000190e6ec48 _UIGestureRecognizerSendActions + 212 
9 UIKit       0x0000000190cfd284 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 376 
10 UIKit       0x00000001910fc03c ___UIGestureRecognizerUpdate_block_invoke + 56 
11 UIKit       0x0000000190cbe240 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 284 
12 UIKit       0x0000000190cbcb1c _UIGestureRecognizerUpdate + 208 
13 CoreFoundation     0x000000018dcc3854 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28 
14 CoreFoundation     0x000000018dcc0adc __CFRunLoopDoObservers + 368 
15 CoreFoundation     0x000000018dcc0e68 __CFRunLoopRun + 760 
16 CoreFoundation     0x000000018dc01dcc CFRunLoopRunSpecific + 448 
17 GraphicsServices    0x00000001938e9c08 GSEventRunModal + 164 
18 UIKit       0x0000000190d32fc0 UIApplicationMain + 1152 
19 SP        0x00000001000590e0 main (main.m:14) 
20 libdyld.dylib     0x000000019a7ffa9c start + 0 

Тип Exception: EXC_BAD_ACCESS (SIGSEGV) Теперь здесь код для карты. Я использую раскадровку с autolayout

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

#ifdef DEBUG 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.780528 
                  longitude:-73.961009 
                   zoom:kZoomMin]; 
#else 
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:[LocationManager sharedInstance].currentLocation.coordinate.latitude 
                  longitude:[LocationManager sharedInstance].currentLocation.coordinate.longitude 
                   zoom:12]; 
#endif 

    CGFloat width = [UIScreen mainScreen].bounds.size.width; 
    CGFloat height = [UIScreen mainScreen].bounds.size.height; 

    //Setting map 
    self.mapView = [GMSMapView mapWithFrame:CGRectMake(0, 0, width, height) camera:camera]; 
    self.mapView.settings.compassButton = NO; 
    self.mapView.settings.myLocationButton = NO; 
    self.mapView.accessibilityElementsHidden = NO; 

    self.mapView.myLocationEnabled = YES; 
    self.mapView.buildingsEnabled = NO; 
    self.mapView.indoorEnabled = NO; 
    self.mapView.delegate = self; 

… 
} 

Описание делегата метода markerInfoWindow говорит, что следует избегать изменений размера карты за 500x500 пикселей и избежать изменений маркеров, я удалил все звонки маркеров, но он выходит из строя в любом случае I «Я пытаюсь проверить, использую ли я MapView в основном потоке, я проверил его с помощью [NSThread currentThread] и, кажется, всегда в главной теме, пожалуйста, дайте мне знать, если есть лучший способ проверить его.

#pragma mark - GMSMapViewDelegate 

- (UIView *)mapView:(GMSMapView *)mapView 
    markerInfoWindow:(GMSMarker *)marker 
{ 

    UIView *infoWindow = [[UIView alloc] init]; 
    infoWindow.frame = CGRectMake(0, 0, 240, 54); 
    infoWindow.backgroundColor = [UIColor clearColor]; 
    infoWindow.layer.cornerRadius = 10; 
    infoWindow.layer.masksToBounds = YES; 
    infoWindow.layer.borderColor = (__bridge CGColorRef)([UIColor blackColor]); 
    infoWindow.layer.borderWidth = 5; 

    ParkingLot *parkingLot = (ParkingLot *)marker.userData; 

    if (![parkingLot isKindOfClass:[ParkingLot class]]) 
    { 
     return nil; 
    } 

    NSString *backgroundImageName = nil; 

    switch ([parkingLot.parentCompanyId intValue]) 
    { 
     case 1: 
      backgroundImageName = @"00_logo_pin_globo_b.png"; 
      break; 

     case 2: 
      backgroundImageName = @"00_logo_pin_globo_c.png"; 
      break; 

     case 3: 
      backgroundImageName = @"00_logo_pin_globo_a.png"; 
      break; 

    } 

    UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:backgroundImageName]]; 
    CGRect frame = background.frame; 
    frame.origin.y++; 
    frame.origin.x++; 
    [background setFrame:frame]; 
    [infoWindow addSubview:background]; 

    UILabel *locationName = [[UILabel alloc] init]; 
    locationName.font = [UIFont fontWithName:@"Helvetica" size:12]; 
    locationName.frame = CGRectMake(45, 10, 110, 13); 
    locationName.textColor = [UIColor redColor]; 
    [infoWindow addSubview:locationName]; 

    if ([marker.userData isKindOfClass:[SearchResult class]]) 
    { 
     Address *address = (Address *)marker.userData; 
     ASSERT_CLASS(address, Address); 

     UILabel *addressLabel = [[UILabel alloc] init]; 
     addressLabel.frame = CGRectMake(5, 5, 60, 20); 
     addressLabel.font = [UIFont fontWithName:@"Helvetica" size:12]; 
     [addressLabel setTextColor:[UIColor whiteColor]]; 
     [infoWindow addSubview:addressLabel]; 

     addressLabel.text = address.name; 

     [infoWindow setFrame:CGRectMake(0, 0, 100, 30)]; 
     infoWindow.backgroundColor = [UIColor blackColor]; 
     [background removeFromSuperview]; 
    } 
    else 
    { 
     UILabel *addressLabel = [[UILabel alloc] init]; 
     addressLabel.frame = CGRectMake(45, 22, 90, 20); 
     addressLabel.font = [UIFont fontWithName:@"Helvetica" size:8]; 
     addressLabel.text = parkingLot.lotAddress; 
     addressLabel.lineBreakMode = NSLineBreakByWordWrapping; 
     [addressLabel setNumberOfLines:2]; 

     [infoWindow addSubview:addressLabel]; 

     if ([parkingLot.hasCoupon intValue] == 1) 
     { 
      UIImageView *hasCouponImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"00_logo_icon_%_.png"]]; 
      [hasCouponImageView setCenter:CGPointMake(background.frame.size.width - (hasCouponImageView.frame.size.width * 2.4), background.frame.size.height * 0.45)]; 
      [infoWindow addSubview:hasCouponImageView]; 
     } 

     locationName.text = parkingLot.locationName; 
    } 

    return infoWindow; 
} 

- (void)mapView:(GMSMapView *)mapView didTapInfoWindowOfMarker:(GMSMarker *)marker 
{ 
    ParkingLot *parkingLot = [marker userData]; 

    [self.delegate pushToParkingLot:parkingLot]; 
} 

- (BOOL)mapView:(GMSMapView *)mapView didTapMarker:(GMSMarker *)marker 
{ 

    if ([self.mapView isEqual:self.informationWindowsMarker.map]) 
    { 
     if(marker.position.latitude != self.informationWindowsMarker.position.latitude && 
      marker.position.longitude != self.informationWindowsMarker.position.longitude) 
     { 
      [self.informationWindowsMarker setOpacity:1]; 
      TRACE(@"%@", [self.informationWindowsMarker debugDescription]); 
     } 
    } 

    self.informationWindowsMarker = nil; 

    self.informationWindowsMarker = marker; 

    [marker setOpacity:0]; 

    return NO; 
} 

- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate 
{ 
    if ([self.mapView isEqual:self.informationWindowsMarker.map]) 
    { 
     ParkingLot *parkingLot = (ParkingLot *)self.informationWindowsMarker.userData; 

     if (![self.informationWindowsMarker.icon isEqual:[parkingLot logoMarkerImage]]) 
     { 
      self.informationWindowsMarker.icon = [parkingLot logoMarkerImage]; 
     } 

     [self.informationWindowsMarker setOpacity:1]; 
    } 
} 
+0

http://stackoverflow.com/questions/23130322/exc-bad-access-sigsegv-on-osx-10-9-2-with-qt-application?answertab=votes#tab-top. Может быть, этот ответ может помочь. – KayAnn

ответ

0

Удаление

infoWindow.layer.cornerRadius = 10; 
infoWindow.layer.masksToBounds = YES; 
infoWindow.layer.borderColor = (__bridge CGColorRef)([UIColor blackColor]); 
infoWindow.layer.borderWidth = 5; 

решил аварию

Я не совсем уверен, почему, но изменяя свойства слоя использует CoreAnimation, и что может использовать свой собственный поток, чтобы изменить его после создания нестабильного состояния для API Google,

Смежные вопросы