2013-09-25 3 views
-1

Где можно хранить изображения из приложения ios программно в iOS-симуляторе/устройстве, отличном от каталога документов/NSuserdefaults? Есть ли способ сохранить изображения в фотоальбоме устройства (это делается программно)? Пожалуйста, предложитеСохранение изображений в устройстве ios

+0

Возможный дубликат [Как сохранить фотографию в библиотеке фотографий iPhone?] (Http://stackoverflow.com/questions/178915/how-to-save-picture-to-iphone-photo-library) – Amar

ответ

3

Вы можете сохранять изображения в фотоальбоме, используя

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

Check the documentation here

2

Вы можете использовать кэш-каталог для хранения изображений. Данные, которые могут быть загружены повторно или регенерированы, должны храниться в <Application_Home>/Library/Caches directory.

Данные, которые используются только временно, должны храниться в <Application_Home>/tmp directory.

Прочтите подробности Data storage Guidelines

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 
+0

Это прекрасно работает , Могу ли я назвать это изображение? Я хочу поместить имя, а затем сохранить. – Shruthi

+0

нет способа назвать изображение – lanbo

0

Если вам не нужен образ опубликован .. Он должен хранить в папке Documents. Пользователи не захотят, чтобы изображение не было записано в их фотоальбом.

Смежные вопросы