Skip to content

Commit

Permalink
hide map view & update image view instead during export for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
incanus committed Mar 15, 2012
1 parent 7df3a91 commit 83bbe37
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Mapresent/DSMRMainViewController.m
Expand Up @@ -529,6 +529,10 @@ - (void)beginExport

[cancelButton addTarget:self action:@selector(pressedExportCancel:) forControlEvents:UIControlEventTouchUpInside];

UIImageView *exportSnapshotView = [[UIImageView alloc] initWithFrame:self.view.bounds];

[self.view addSubview:exportSnapshotView];

exportModal.frame = self.timelineView.frame;
exportModal.alpha = 0.0;

Expand Down Expand Up @@ -572,10 +576,17 @@ - (void)beginExport

[self resetMapView];

self.mapView.hidden = YES;

self.videoExporter = [[DSMRVideoExporter alloc] initWithMapView:self.mapView markers:self.markers];

self.videoExporter.delegate = self;

[self.videoExporter addObserverForKeyPath:@"exportSnapshot" task:^(id obj, NSDictionary *change)
{
dispatch_async(dispatch_get_main_queue(), ^(void) { exportSnapshotView.image = ((DSMRVideoExporter *)obj).exportSnapshot; });
}];

[self.videoExporter exportToPath:[[self documentsFolderPath] stringByAppendingPathComponent:@"export.mp4"]];
}];

Expand All @@ -597,8 +608,13 @@ - (void)cleanupExportWithBlock:(BKBlock)block
{
[UIApplication sharedApplication].idleTimerDisabled = NO;

[self.videoExporter removeAllBlockObservers];

[[self.view.subviews lastObject] removeFromSuperview]; // shield view
[[self.view.subviews lastObject] removeFromSuperview]; // export view
[[self.view.subviews lastObject] removeFromSuperview]; // snapshot view

self.mapView.hidden = NO;

[UIView animateWithDuration:0.25
animations:^(void)
Expand Down

0 comments on commit 83bbe37

Please sign in to comment.