2010-11-24 82 views
1

我有一个MKMapView与滚动和userInteraction禁用内UITableViewCell。所需效果(实际上是某个位置的地图的静态图像)效果非常好,但当MKMapView在屏幕上移动(滚动)时,它会重新加载地图,偶尔会导致应用程序崩溃。我已经装的自定义UITableViewCell像任何其他UITableViewCellcellForRowAtIndexPath停止MKMapView从重新加载

if(indexPath.section == 0 && indexPath.row == 0) 
{ 
    MapTableViewCell *cell = (MapTableViewCell *)[tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"%@Map", cellIdentifier]]; 

    if(cell == nil) 
    { 
     cell = [[[MapTableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:cellIdentifier] autorelease]; 
    } 

    NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MapTableViewCell" owner:self options:nil]; 

    for(id currentObject in topLevelObjects) 
    { 
     if([currentObject isKindOfClass:[UITableViewCell class]]) 
     { 
      cell = (MapTableViewCell *)currentObject; 
      break; 
     } 
    } 

    return cell; 
} 

我发现,这个当前方法,如果你让地图图像加载移动UITableView之前,那么它的确定。但是如果你在完成加载之前将它从屏幕上移开,它会崩溃! :(

我只想指出我不希望能够以任何方式控制地图或显示任何注释。我确实尝试截图地图视图,将其隐藏在屏幕上并显示该屏幕截图作为UITableViewCell一个UIImageView但是这是不够快

编辑:!。更新后的代码这是此方法的全部代码是我的自定义TableViewCell页头不正确这里

+0

不明显的结果你实际上想要实现。粗略猜测,如果MKMapView的委托是单元格,那么您可能需要在单元格的-dealloc中取消设置委托。我也无法弄清楚你的笔尖加载应该做什么。 – 2010-11-24 01:07:38

回答

1

由于TC的答案(以上注释)。

需要什么是我释放MKMapView在自定义UITableViewCell dealloc方法。

1

尝试设置的区域?地图/你想要的地图的范围,然后更改userInteractionEnabled和zoomEnabled的属性。所以可能是这样的:

MKCoordinateRegion region; 
region.center = "location"; //a CLLocationCoordinate2D location of where ever 

MKCoordinateSpan span; 
span.latitudeDelta = 0.03; //desired size for both latDelta and lonDelta 
span.longitudeDelta = 0.03; 
region.span = span; 

[mapView setRegion:region animated:YES]; 

然后在属性试试这个:

mapView.zoomEnabled = NO; 
mapView.userInteractionEnabled = NO; 
相关问题