This question has been asked before but there were no answers for Swift 3. I am looking for the same solution which I am stuck for the past 3 weeks.
I have done my research and watched numerous Youtube videos about loading images from Photos/Camera Roll into the app using UIImagePickerController but I want to access the photos without user actions.
I want to read a series of photos from camera roll and put them in a photo slide to show them one by one. How can I access these photos without UIImagePickerController?
You can use the
Photos
framework to fetch the photos from CameraRoll/Photos.Here is the version of Swift 3 code.
Import the photos framework
Use this function to fetch the photos, somewhere in
viewDidLoad
or on your action wherever you want to fetch the photos.Rest are UICollectionView Datasource and Delegates. See the
cellForItem
datasource method on How to show the image.Adjust the below delegates as per your need.
Make sure to keep the photos permission ON. If you click Don't Allow, then you have to manage the authorization too using
PHPhotoLibrary.authorizationStatus()
You can read more about Photos framework.