Delete Images From iOS Photo Gallery [duplicate] - ios

This question already has answers here:
ALAssetsLibrary delete ALAssetsGroup / ALAsset
(6 answers)
Closed 9 years ago.
I have created an Application that fetches Images from the photo library of the phone and displays it on a collection view.
Now, I want that whenever the user selects an image and click on a delete button that particular image gets deleted from the collection view as well as from the image library.
I am using ALAssetLibrary to fetch the images.
I searched a lot but did not find any way to delete the image from the photo library.
Can anybody tell me that how I can delete a photo from photo library programmatically from my application.

You can copy files from the gallery into your application's file system sandbox, where you can do anything you want with them. However, your application can't modify files outside the sandbox. This includes files in the gallery.
As this answer says, there doesn't appear to be a method defined for deleting photos there.

Related

UIImagePickerController - Remember last album

My app allows users to pick images from Photo Library.
I use UIImagePickerController for this.
User may want to pick image from nested folders and finaly from particular album.
When user wants to pick another image again, the odds are good they will want to get image from the same album as previously.
Is there any way to instruct UIImagePickerController to show particular album (in this scenario the one from which previous image was loaded) when opening a new image ?
I found a similar question asked 10 years ago with negative answer, but since then maybe something have changed... [?]
Open UIImagePickerController to custom photo album?

How to add an image as background at run time in swift and keep it?

Good morning I am writing an app in Swift 3.1, and one of the features that I would like to provide is that the user can choose their own background for the main View and keep it as part of the application.
I know how to do it at design time, but what I want is to allow the user once they install the application on their devices to select a picture from the photo library and use that as background of the main View. Also I would like to make sure the app doesn't the depend on the photo library after the image was set as background, in other words, I want to copy the image to the app so if the user deletes the image from the photo library, I have a copy of the image as part of the app.
May I ask if what I want to achieve is possible? If so may I ask for some code guidance please?
Thanks in advance.
Yes this can be acheive by following steps:
1) You need to implement UIImagePickerController to select a photo from photos library.
https://turbofuture.com/cell-phones/Access-Photo-Camera-and-Library-in-Swift
2) You need to write a code to save that image in your Application document folder
https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html
3) You need to write code to delete the existing image otherwise app size will increase.
Delete files from directory inside Document directory?
4) Get image from Application document folder and add it to your view as background.
https://iosdevcenters.blogspot.com/2016/04/save-and-get-image-from-document.html

Accessing Images from gallery and showing in iOS app gallery

I have around 1000 ’s of Images, I want show them in my app. What are the possibilities to do that..
The ideas which I’m thinking
1.Saving all images in phone gallery. accessing images form gallery… but It seems not possible as each iOS app has its own sandbox.
2.Saving in my bundle which will increase the memory size.
In android there is a control called “ViewPager”, how can i achieve the same control in iOS ….
Tried scrollview with paging technique but crashes due to memory ....
Please guide me…..
I dont think you can show images from the gallery directly to your application . But you can store it into document directly , for that you have to first pick images from the gallery . you can refer
How to load photos from photo gallery and store it into application project?
And next time when you start application you can load images from the document directory so you dont need to go to the gallery again .

iOS take pictures in album and then show them

What would be the best way in iOS 7 to take pictures inside a custom album (Named after my application) and then show the custom album.
I mean, I could add those pictures in a group using AssetsLibrary but there's some way to show them afterwards without having to create a custom gallery?
https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html the sample app is included. take a look

Custom image name on iOS

I'm developing an iPhone application, which has similar functionality to Camera Roll. In full size mode (e.g. viewing selected image in full size), I want to display the picture name (image file name).
The problem here: If the user changes the picture name on their PC and upload the picture back to their iPhone, I'm still getting original file name (e.g. "IMG_xxx), while I would like to get the name given by user. If I go to MyPictures on my iPhone, I do see user custom names.
How I can get a custom image name?
Thanks!
simple answer is No. You cannot do what are requesting.
In your app you can call an image whatever you want but once you save it to iPhone/iPad camera roll then it is renamed automatically by iOS. We developers have no control over that behavior.
Now if you were to save that picture in your apps document dir and some how let the user download / upload those pics using iTunes file sharing then perhaps that may work for you.

Resources