Create a gallery for local app content in iOS - ios

My app takes some videos and pictures and stores them in the Application Home/Documents folder. I want to create a gallery that will open and display (and playback) these items. I looked into MPMediaPickerController and it looks like the only option for data source there is the Photos Album.
It looks like I will have to go with creating UICollectionView. Is this the right way to do this or is there another way similar to MPMediaPickerController but with setting the source to an array of data objects?

The best way to do it is use your own implementation UICollectionView. MPMediaPickerController mainly works for media related(especially for songs and videos)
Since you have images and videos just use NSFilemanager to get the files in Documents Directory and pass the information to UICollectionView datasource and handle the touch actions on the UICollectionView didSelect methods.

Related

Inserting An Image from UIImagepicker into UICollectionViewCell Swift

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!)

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

Displaying both video and image in a single view element

I'm attempting to create an Instagram styled app and cannot figure out a way to display media in a UITableView the way they do (either video or image in a single view). I know it most likely is a custom implementation of UIWebView or something of the sort, however I have no idea where to even begin writing a subclass like that. Things I've already tried include:
Using a UIWebView (massive memory leak, even when adding/removing the views programmatically).
Adding either UIImageView or UIWebView depending on whether or not it was a video or image (again had a memory leak)
Searching the internet for a possible way to do this
If anyone could help me out that would be awesome! FYI the media I am using is grabbed straight from my server, there is no data being gathered from a popular source such as YouTube, Flickr, etc.
i think they use UICollectionview as it allows for better customization of a table.
In terms of images and videos, use UIImageView to display all your images and MPMoviePlayerController to play videos.

QLPreviewController with ALAsset items

I'm getting a list of ALAsset items (images and videos) from a specific photo album and trying to view them using a QLPreviewController.
Unfortunately because ALAsset doesn't provide a real file url, just the "assets-library://" type url, viewing them in a QLPreviewController using just that url isn't possible.
My only solution was to first copy each of those ALAssets into the Documents folder inside my app (getting the raw data from an ALAssetRepresentation and saving it in a file), and viewing those with the QLPreviewController, but it ends up being too slow and sluggish when the number or size of files gets bigger.
Is there any way to get this done? Is there any other way to enumerate through the items inside a photo album that would return a true filesystem URL? Or should I just try to make my own preview controller with UIImageViews and MPMovieControllers and recreate all the functionality (swipe, share, etc)?

creating an interactive page (videos, photos) for sharing on iOS device

I am building an iOS app, using storyboard. I have created a page where the user can create a page that will then be then published on DropBox and shared between all app users. this page lets you add photos, videos (not yet), and textviews (with scrolling enabled). Until know when the user presses the upload button, a screenshot is taken and uploaded, then views from a table view. but obviously it is just an image, so you can't scroll the textfields to see all the content and if I wanted to add the video support it would not be able to play it. I tried doing research on the internet, but I am a bit confused. Do I have to save all the components (UITextField...) separately, and place them in the same DropBox folder, and then put them all back together? What do you suggest? Is there a way?
Of course you will have to save the data separately...how else would your program know how to create the view? I recommend JSON or XML. Don't ask about how to structure it, that is a different question and one you should think about yourself.

Resources