// Create an image for the view and save it to the Photos library
- (void)savePhotoOfView
UIView *)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[view drawRect:view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo
,
NULL);
}
// Called by UIImageWriteToSavedPhotosAlbum() when it completes
- (void) savedPhotoImage
UIImage *)image
didFinishSavingWithError
NSError *)error
contextInfo
void *)contextInfo
{
NSString *message = @"This image has been saved to your Photos album";
if (error) {
message = [error localizedDescription];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle
"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
The above code is storing a blank viewin the photo album.Can anyone tell what is the wrong in the code?
- (void)savePhotoOfView
{
UIGraphicsBeginImageContext(view.bounds.size);
[view drawRect:view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo
NULL);
}
// Called by UIImageWriteToSavedPhotosAlbum() when it completes
- (void) savedPhotoImage
didFinishSavingWithError
contextInfo
{
NSString *message = @"This image has been saved to your Photos album";
if (error) {
message = [error localizedDescription];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle
otherButtonTitles:nil];
[alert show];
[alert release];
}
The above code is storing a blank viewin the photo album.Can anyone tell what is the wrong in the code?