2017-06-30 3 views
0

あらゆる場所ビュー内のコントローラUIやマップをクラッシュを取得しますそれはまた、列挙されている間に例外がコレクションについてです見ての通り(この場合には、それは配列です)私の英語は、ランダムに私がクラッシュをgetingい

[weakSelf performSelectorInBackground:@selector(googleMapView) withObject:nil]; 

googleMapView{ 
    [mapView animateToZoom:15]; 

    int k=0; 
    @try { 

     GMSMutablePath *path = [GMSMutablePath path]; 

     for(DRMapView * object in self.mapViewDataArray) 
     { 
      mMapViewObj=object; 

      GMSMarker * markersLocal = [[GMSMarker alloc] init]; 

      pinImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,40+20*isiphone6Plus()+20*isiphone6(),60)]; 

      markersLocal.position = CLLocationCoordinate2DMake(mMapViewObj.mLatitude, mMapViewObj.mLongitude); 
      [path addCoordinate: markersLocal.position]; 


      view = [[UIView alloc] initWithFrame:CGRectMake(0,0,40+20*isiphone6Plus()+20*isiphone6(),60)]; 
      view.backgroundColor=[UIColor blackColor]; 
      pinImageView.contentMode = UIViewContentModeScaleAspectFit; 
      NSString * imageWithPercent; 
      label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 12.5, 12.5)]; 
      if ([mMapViewObj.mGenderRatio isEqualToString:@""]) 
      { 
       label.text [email protected]"0"; 
       imageWithPercent =[NSString stringWithFormat:MAP_NO_ONE]; 
       pinImageView.image = [UIImage imageNamed:imageWithPercent]; 
      } 
      else 
      { 
       //    NSString *genderRatio =[NSString stringWithFormat:@"%@",[DrinkrCommon valueOrNil:[[dict objectForKey:kGenderRatio] objectForKey:kMale]]]; 
       label.text =mMapViewObj.mTotalMembers; 

       int percentage = [mMapViewObj.mMaleFemaleRatio intValue]; 

       if (percentage >= 80) { 
        imageWithPercent =[NSString stringWithFormat:@"map80"]; 
        //NSLog(@"80====>>> %d",percentage); 
       } 
       else if (percentage >= 60) { 
        // NSLog(@"60====>>> %d",percentage); 
        imageWithPercent =[NSString stringWithFormat:@"map60"]; 
       } 
       else if (percentage == 50) { 
        // NSLog(@"50====>>> %d",percentage); 
        imageWithPercent =[NSString stringWithFormat:@"map50"]; 
       } 
       else if (percentage >= 40) { 
        // NSLog(@"40====>>> %d",percentage); 
        imageWithPercent =[NSString stringWithFormat:@"map40"]; 
       } 
       else if (percentage >= 20) { 
        // NSLog(@"20====>>> %d",percentage); 
        imageWithPercent =[NSString stringWithFormat:@"map20"]; 
       } 
       else if (percentage <= 20) { 
        // NSLog(@"<20====>>> %d",percentage); 

        imageWithPercent =[NSString stringWithFormat:@"map100"]; 

       } 

       pinImageView.image = [UIImage imageNamed:imageWithPercent]; 
      } 
      pinImageView.contentMode = UIViewContentModeScaleAspectFit; 

      [label setTextColor:[UIColor whiteColor]]; 
      [label setBackgroundColor:[UIColor blackColor]]; 
      [label sizeToFit]; 
      label.layer.cornerRadius=label.frame.size.height/2; 
      label.layer.masksToBounds = YES; 
      label.adjustsFontSizeToFitWidth=YES; 
      label.center=pinImageView.center; 
      view.center=pinImageView.center; 
      view.backgroundColor=[UIColor clearColor]; 
      [view addSubview:pinImageView]; 
      [view addSubview:label]; 
      UIImage * markerIcon = [self imageFromView:view]; 

      markersLocal.userData=[NSNumber numberWithInt:k+1]; 
      markerView = [[UIImageView alloc] initWithImage:markerIcon]; 
      markerView.tintColor = [UIColor blackColor]; 
      markersLocal.iconView = markerView; 
      // markers.map = mapView; 
      marker=markersLocal; 

      //  marker=m/MapViewObj.viewMarker; 
      marker.map=mapView; 
      k++; 
     } 

     GMSCoordinateBounds * bounds = [[GMSCoordinateBounds alloc] initWithPath:path]; 
     [mapView animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:20.0f]]; 
    } 
    @catch (NSException *exception) { 
    } 
    @finally { 
    } 
} 

答えて

0

ためme.sorryを示唆しては修正されています。

"コレクションCALayerArray"は、レイヤーの配列(レイヤーですべてバックアップされたUIViewのインスタンス)を意味し、removeFromSuperviewまたはaddSubviewを呼び出すときに変更が発生します。列挙は、再描画中にいつでも実行できます。

は、だから私はあなたの問題は、これらの2行になると思う:RPL @Eridanaため

[view addSubview:pinImageView]; 
[view addSubview:label]; 
+0

おかげで、私は現金でも、テーブルビュー –

+0

あなたは歓迎されている場所ごとに取得しています。あなたのコードを見直し、「ビュー」がどこにあるのかを調べてみてください。そして第2に、すべてのUI操作をメインスレッドで呼び出さなければなりません。 – Eridana

+0

私は既に自分のコードを見直していますが、私はこの方法でのみ "ビュー"を使用しています。 –

関連する問題