save image in photo album when button click in iphone
-
14-07-2021 - |
Question
in My Application there is one galary. i dont know what to put in image(UIImage *image) part of the UIImageWriteToSavedPhotosAlbum Method and I wann save image in iphone photo album. I am using this code
- (void)savePhoto
{
UIImageWriteToSavedPhotosAlbum(((IndicatorImageView *)[self._imageViews objectAtIndex:_selectedImage])._imageView.image, nil, nil, nil);
}
but it shows this error...
2012-10-26 18:48:00.596 PhotoGallery[2683:15203] -[GalleryItemView _imageView]: unrecognized selector sent to instance 0x8e7cc90 2012-10-26 18:48:00.665 PhotoGallery[2683:15203] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GalleryItemView _imageView]: unrecognized selector sent to instance 0x8e7cc90' * First throw call stack:
Please help me if u know this... thanks in advance...
Solution
- (void)savePhoto
{
UIImageWriteToSavedPhotosAlbum(((IndicatorImageView *)[self.imageViews objectAtIndex:_selectedImage]).image, nil, nil, nil);
}
If your array self._imageViews
contain imageViews , why you try to access _imageView
again??
also , Is _imageViews
a property? use self.imageViews
is better.
OTHER TIPS
UIImageWriteToSavedPhotosAlbum(YOUR_IMAGE(UIImage), self, @selector(finishUIImageWriteToSavedPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);
Here is the code you need. You need to pick the imageview.image.....not the actual image variable.
- (IBAction)saveImageButton:(id)sender {
UIImageWriteToSavedPhotosAlbum(_processedImageView.image, nil, nil, nil);
}