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

后端 未结 1 520
时光说笑
时光说笑 2020-12-31 16:04

I am using swift to load images from photo library. I know that I can use UIImagePickerController to let user to choose the images from camera roll but I want to access phot

相关标签:
1条回答
  • 2020-12-31 16:54

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

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

    The code is written in Objective-C rather than Swift, but you could do the same using Swift. Ask questions if any.

    0 讨论(0)
提交回复
热议问题