i\'m trying to put a MKMapView in some UiTableViewCell but (on iPhone 5, so even in other devices), when the app load the cell with the map, the scroll become not too smooth
Based on your answer, you can also create the snapshot in background and execute the result on the main queue (don't forgive to check the error before update your cell):
if ( IS_IOS7 ) {
cell.objectImage.image = [UIImage imageNamed:@"mapPlaceholder"];
// Cooridinate
MKCoordinateRegion region;
region.center = activity.object.location.coordinate;
MKCoordinateSpan span;
span.latitudeDelta = 0.055;
span.longitudeDelta = 0.055;
region.span = span;
[self.mapViewForScreenshot setRegion:region animated:NO];
MKMapSnapshotOptions *options = [[MKMapSnapshotOptions alloc] init];
options.region = self.mapViewForScreenshot.region;
options.scale = [UIScreen mainScreen].scale;
options.size = CGSizeMake(300, 168);
MKMapSnapshotter *snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options];
dispatch_queue_t executeOnBackground = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
[snapshotter startWithQueue:executeOnBackground completionHandler:^(MKMapSnapshot *snapshot, NSError *error) {
dispatch_async(dispatch_get_main_queue(), ^{
if (!error) {
cell.objectImage.image = snapshot.image;
cell.mapPinImageView.hidden = NO;
}
});
}];
}];
} else {
cell.mapPinImageView.hidden = NO;
[cell.objectImage setImageWithURL:[NSURL URLWithString:@""] placeholderImage:nil];
}