5

MKMapViewを含むUITableViewCellsを備えたUITableViewがあります。

問題:テーブルセルが選択されてからマップを移動すると、マップビューがすべて白になり、「リーガル」ラベルのみが表示されます。

誰かがこれを以前に経験したことがありますか?

スクリーンショット

コード全体は次のとおりです。

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.table.backgroundColor = [UIColor clearColor];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 5;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 70;
}

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

    MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 220, 70)];

    MKCoordinateSpan span = MKCoordinateSpanMake(0.01, 0.01);
    CLLocationCoordinate2D logCord = CLLocationCoordinate2DMake(47.606, -122.332);
    MKCoordinateRegion region = MKCoordinateRegionMake(logCord, span);
    [map setRegion:region animated:NO];

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"aaaa"];
    [cell.contentView addSubview:map];

    return cell;
}
4

2 に答える 2

4

私はこれを経験しました。

私の場合、tableView またはセルに backgroundColor があり、そのセルにグレーまたはブルーの選択スタイルがあり、セルがデキューによってリサイクルされると、マップはこのように白くなります。

こうすればマップが真っ白にならない気がする

cell.selectionStyle = UITableViewCellSelectionStyleNone;
于 2013-02-12T19:39:24.823 に答える
0

私もこれを経験しました。

別の詳細ビューコントローラーを押したりポップしたりした後にタッチすると、マップの背景が白くなりました。TableViewにはまだ色/背景が設定されていません。すべてがデフォルトです。

 cell.selectionStyle = UITableViewCellSelectionStyleNone;

...実際に助けました。

于 2013-02-23T13:08:21.400 に答える