简体   繁体   English

在iPhone中单击按钮时将图像保存在相册中

[英]save image in photo album when button click in iphone

in My Application there is one galary. 在我的应用程序中,有一个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. 我不知道要在UIImageWriteToSavedPhotosAlbum方法的image(UIImage * image)部分中放置什么,我想将图像保存在iPhone相册中。 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: 2012-10-26 18:48:00.596 PhotoGallery [2683:15203]-[GalleryItemView _imageView]:无法识别的选择器已发送到实例0x8e7cc90 2012-10-26 18:48:00.665 PhotoGallery [2683:15203] *由于未捕获而终止了应用程序异常'NSInvalidArgumentException',原因:'-[GalleryItemView _imageView]:无法识别的选择器发送到实例0x8e7cc90'*首先抛出调用堆栈:

Please help me if u know this... thanks in advance... 如果您知道这一点,请帮助我。

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. 您需要选择imageview.image .....而不是实际的image变量。

- (IBAction)saveImageButton:(id)sender {
UIImageWriteToSavedPhotosAlbum(_processedImageView.image, nil, nil, nil);
}
- (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?? 如果您的数组self._imageViews包含self._imageViews ,为什么_imageView尝试再次访问_imageView

also , Is _imageViews a property? 还, _imageViews是属性吗? use self.imageViews is better. 使用self.imageViews更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM