How do I save a MapView to the PhotoAlbum for later attachment to an email created within my iPhone application?
A:
Try this:
UIGraphicsBeginImageContext(map.layer.bounds.size);
[map.layer renderInContext:UIGraphicxGetCurrentContext()];
UIImage *mapImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
And perhaps you should also double-check Google's licensing terms if they allow making and distributing screenshots of the maps.
Ole Begemann
2010-07-15 09:07:00
Here is the code that finally worked for me:CGRect screenRect = [[UIScreen mainScreen] bounds]; UIGraphicsBeginImageContext(screenRect.size); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextFillRect( ctx, screenRect ); [self.view.layer renderInContext:ctx]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIImageWriteToSavedPhotosAlbum(viewImage, self, nil, nil);
MadProfit
2010-07-16 21:50:18
Also, one needs to add the Quartzcore framework and use include Quartzcore in the implementation file.
MadProfit
2010-07-16 21:52:57
Programmatically, one can only attach or embed only one photo or picture into an email. Sorta makes sense, otherwise one could imagine someone having some very large emails by program design or accident that would cause the iphone some memory or other issues.
MadProfit
2010-07-27 11:20:24