在后台线程中的uitableviewcell中加载GMSMapView

时间:2016-05-25 13:44:09

标签: objective-c background-thread gmsmapview

我想在单元格内的视图中加载gmsmapview。 下面的代码工作正常。但它的tableview滚动不是smoth。 因为每次mapview都会加载并且需要时间。 是否还有其他选项可以在后台线程中加载mapview

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

 CellMap *cell=[tableView 



                                                  //do the fetching of data here(Don't do any UI Updates)
                                                  GMSMapView *mapView_;

                                                  [GMSServices provideAPIKey:kGoogleKey];
                                                  // Create a GMSCameraPosition that tells the map to display the
                                                  // coordinate -33.86,151.20 at zoom level 6.
                                                  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20
                                                                                                               zoom:6];
                                                  mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
                                                  mapView_.myLocationEnabled = YES;

                                                  // Creates a marker in the center of the map.
                                                  GMSMarker *marker = [[GMSMarker alloc] init];
                                                  marker.position = CLLocationCoordinate2DMake(modelitemobj.latitude,modelitemobj.longitude);
                                                  marker.title = modelitemobj.strCity;
                                                  //marker.snippet = @"Australia";
                                                  marker.map = mapView_;
                                                  mapView_.frame=cell.mapView.frame;
                                                  [cell.mapView addSubview:mapView_];



return cell;
}

请帮帮我

0 个答案:

没有答案