簡體   English   中英

在iPhone中單擊按鈕時將圖像保存在相冊中

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

在我的應用程序中,有一個galary。 我不知道要在UIImageWriteToSavedPhotosAlbum方法的image(UIImage * image)部分中放置什么,我想將圖像保存在iPhone相冊中。 我正在使用此代碼

- (void)savePhoto
{
    UIImageWriteToSavedPhotosAlbum(((IndicatorImageView *)[self._imageViews objectAtIndex:_selectedImage])._imageView.image, nil, nil, nil);

}

但它顯示此錯誤...

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'*首先拋出調用堆棧:

如果您知道這一點,請幫助我。

UIImageWriteToSavedPhotosAlbum(YOUR_IMAGE(UIImage), self, @selector(finishUIImageWriteToSavedPhotosAlbum:didFinishSavingWithError:contextInfo:), nil);

這是您需要的代碼。 您需要選擇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);
}

如果您的數組self._imageViews包含self._imageViews ,為什么_imageView嘗試再次訪問_imageView

還, _imageViews是屬性嗎? 使用self.imageViews更好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM