1

MKMapView内でスクロールとuserInteractionが無効になっていますUITableViewCell。目的の効果(事実上、特定の位置にある地図の静止画像)は非常にうまく機能しますが、MKMapView画面のオンとオフを切り替える(スクロールする)と、地図が再読み込みされ、アプリがクラッシュすることがあります。UITableViewCell私は他のようにカスタムをロードしUITableViewCellましたcellForRowAtIndexPath

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。ただし、読み込みが完了する前に画面から移動すると、クラッシュします。:(

マップを制御したり、マップに注釈を表示したりしたくないことを指摘しておきます。マップビューのスクリーンショットを作成し、画面から非表示にして、そのスクリーンショットをとして表示しようとしUIImageViewましたUITableViewCellが、これは十分な速度ではありませんでした。

編集:更新されたコード。これは、このメソッドの完全なコードです。私のカスタムTableViewCell割り当てはここで正しくありませんか?

4

2 に答える 2

1

答えてくれたtcに感謝します(上記のコメント)。

必要だったのMKMapViewは、カスタムUITableViewCelldeallocメソッドでをリリースすることでした。

于 2010-11-30T11:10:10.570 に答える
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;
于 2010-11-24T02:24:30.807 に答える