Inserting An Image from UIImagepicker into UICollectionViewCell Swift - ios

Hey just wondering if its possible to Select a specific image from the photolibrary and implement into a Collection View
so the idea is to have an image the user can select from the photolibrary then fill the selected image into a cell within the collection view i would also like to be able to save the image so if the user deletes the photo from the library it remains within the application ( was thinking i could save the image within firebase or NSUserdefaults?

A controller demonstrating how to select photos to display in a collection view can be found here.
If you're only going to be saving a single image, then putting it at a known path like demonstrated here would work: How to save a remote image with Swift?
If you're trying to manage multiple images, it's probably a good idea to look into Core Data and have it manage the images' UIImageJPEGRepresentation NSData for you. (Be sure to set "Store in External Record File" for the image data record if you do this!)

Related

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

Set image to the image view from Gallery without select the image from the Image Gallery

I am new to IOS app development. I have one problem. I have to get an image from the Image Gallery of the iPhone without letting the user select the image. I need to programatically set the image name of the image I need to get the Image. Any one please help me.
You can fetch images from Gallery programmatically using AssetLibrary.
These can be helpful Tutorial1 and Tutorial2
This stackoverflow answer could also be helpful
Once the images are fetch you can select and then set it to any UIImageView
Unfortunately what you'd like to do is not allowed on iOS.
You have to use UIImagePickerController, ask permission from the user, and let the user choose an image.
Check this thread: Access Photo Library via Objective-C/Xcode in iOS

ImagePicker from external source and not photo album

I'm looking for a custom control I can put in a UIViewController that has the functionality of UIImagePicker (displaying thumbnails, enable multiselect etc.) but display images from "the server" (a given array of images)
All the ImagePickers I find work directly on the albums as an alternative to UIImagePicker
Does anyone know a nice solution?
You can use this lib called "JPImagePickerController"
https://github.com/jeena/JPImagePickerController
You will make your own DataSource which will take your images which could be provided from disk or bundle

photo filters in iOS

I have a question about applying photo filters in iOS. The filter itself will not be added/adjusted by the user manually, but rather automatically applied to the photo once they categorize and upload their photo to a table view. Simply put, all photos tagged by users in category "x" will be blue in a table UI, all photos in category "B" will be yellow in table UI etc...The photos will be displayed in a view format much like VEVO (if your familiar)...
I am assuming the best way to do this would just to create a class for each category based filter?
Thanks for any help.
Try the Core Image framework, it contains specific methods to apply filters.
https://developer.apple.com/library/ios/documentation/graphicsimaging/reference/coreimagefilterreference/index.html

How to save UIImageView data in iOS

I'm trying to find another way of sending images back fourth over and over again in between ViewControllers without using prepareForSegue. Is there a way to save my image that I loaded up in the UIImageView and then later load it up again when needed in a different ViewController?
I'm trying to create an app that builds an object using multiple images layering on top of each other.
[UIImage imageNamed:] stores the image in a cache, but it only works for images in your application bundle. If you want to load images in your documents directory, you should look into building your own cache to load them.

Resources