gpt4 book ai didi

cocoa-touch - UITableViewCell 内的 MKMapView

转载 作者:行者123 更新时间:2023-12-04 20:13:34 25 4
gpt4 key购买 nike

我有一个带有 UITableViewCells 的 UITableView,其中包含一个 MKMapView。

问题:如果表格单元格被选中,然后移动 map ,你会看到 map View 是全白的,你只能看到“合法”标签。

有谁之前经历过这个吗?

screenshot

这是整个代码:

@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;
}

最佳答案

我有过这种经历。

在我的情况下,如果它的 tableView 或单元格具有 backgroundColor 并且其单元格具有灰色或蓝色选择样式并且单元格通过出队回收,则 map 会变成这样的白色。

我认为如果 map 不会像这样变白

cell.selectionStyle = UITableViewCellSelectionStyleNone;

关于cocoa-touch - UITableViewCell 内的 MKMapView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14823185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com