I have a UITableView with UITableViewCells that contains a MKMapView.
The Problem: if the table cell ever gets selected, then move the map, you see the mapview is all white and you only see the "Legal" label.
Has anyone experienced this before?
Here is the entire code:
@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;
}
I have experienced this.
In my case, the map becomes white like this if its tableView or cell has a backgroundColor and its cell has either a gray or blue selection style and the cell is recycled through dequeue.
I think that the map won't turn white like this if
cell.selectionStyle = UITableViewCellSelectionStyleNone;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With