Swift: How to load photos from photo library without using UIImagePickerController?

I use fast download images from photo library. I know that I can use the UIImagePickerController to allow the user to select images from the camera’s movie, but I want to access the photos without user action. For example, I want to read a series of photographs taken from a camera roll and put them in a slide show to show them one at a time. How can I access these photos without UIImagePickerController?

+6
source share
1 answer

You can access the photo library using the Photos framework (for iOS 8+). Take a look at this example. In the AAPLRootListViewController code, if the awakeFromNib method you can see how to create a PHFetchResult object to retrieve specific photo data. Then, in the AAPLAssetGridViewController, PHAsset objects (from PHFetchResult) are used to retrieve the actual image data. Take a look at the method

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 

The code is written in Objective-C, not Swift, but you can do the same with Swift. Ask questions, if any.

+6
source

All Articles