I have MKMapView built into UITableViewCell. From time to time, the partition is reloaded. The problem is that the map cell decided to run all of a sudden when an update occurs.
Here is the base code
- (void)viewDidLoad
{
[super viewDidLoad];
_mapCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Map"];
[_mapCell setSelectionStyle:UITableViewCellSelectionStyleNone];
[_mapCell setBackgroundColor:[UIColor greenColor]];
_mapView = [[MKMapView alloc] init];
[_mapView setTranslatesAutoresizingMaskIntoConstraints:NO];
[_mapCell.contentView addSubview:_mapView];
[_mapCell.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_mapView]|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_mapView)]];
[_mapCell.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_mapView]|" options:0 metrics:0 views:NSDictionaryOfVariableBindings(_mapView)]];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[_mapCell setSelectionStyle:UITableViewCellSelectionStyleNone];
return _mapCell;
}
And the reboot code
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
double delayInSeconds = 2.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
});
}
Here is an example project to demonstrate the problem.
Note: JIT for tableview is logical if used with maps. Therefore, I created iVar for it and launched it earlier.
source
share