-1

除了文档目录/ NSuserdefaults,我可以在哪里以编程方式将来自 ios 应用程序的图像存储在 ios 模拟器/设备中?有没有办法将图像存储在设备相册中(以编程方式完成)?请建议

4

4 回答 4

3

您可以使用将图像保存到相册

UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void *contextInfo);

在此处查看文档

于 2013-09-25T08:48:03.447 回答
2

您可以使用缓存目录来存储图像。可以再次下载或重新生成的数据应存储在<Application_Home>/Library/Caches directory.

仅临时使用的数据应存储在<Application_Home>/tmp directory.

阅读此内容了解详细信息数据存储指南

于 2013-09-25T08:48:22.147 回答
2
UIImageWriteToSavedPhotosAlbum
Adds the specified image to the user’s Camera Roll album.

void UIImageWriteToSavedPhotosAlbum (
   UIImage  *image,
   id       completionTarget,
   SEL      completionSelector,
   void     *contextInfo
);
Parameters
image
The image to write to the Camera Roll album.
completionTarget
Optionally, the object whose selector should be called after the image has been written to the Camera Roll album.
completionSelector
The method selector, of the completionTarget object, to call. This optional method should conform to the following signature:
- (void)               image: (UIImage *) image
    didFinishSavingWithError: (NSError *) error
                 contextInfo: (void *) contextInfo;
contextInfo
An optional pointer to any context-specific data that you want passed to the completion selector.
Discussion
When used with an image picker controller, you would typically call this function within your imagePickerController:didFinishPickingMediaWithInfo: delegate method implementation.

The use of the completionTarget, completionSelector, and contextInfo parameters is optional and necessary only if you want to be notified asynchronously when the function finishes writing the image to the user’s Camera Roll or Saved Photos album. If you do not want to be notified, pass nil for these parameters.

When used on an iOS device without a camera, this method adds the image to the Saved Photos album rather than to the Camera Roll album.

Availability
Available in iOS 2.0 and later.
See Also
UISaveVideoAtPathToSavedPhotosAlbum
于 2013-09-25T08:52:34.510 回答
0

如果您不需要发布图像。它应该存储在 Documents 文件夹中。用户不希望将不伦不类的图像保存到他们的相册中。

于 2013-09-25T09:12:24.293 回答