[英]swift: How to load photos from photo library without using UIImagePickerController?
I am using swift to load images from photo library. 我正在使用swift从照片库加载图像。 I know that I can use UIImagePickerController to let user to choose the images from camera roll but I want to access photos without user actions.
我知道我可以使用UIImagePickerController让用户从相机胶卷中选择图像,但我想在没有用户操作的情况下访问照片。 For example, I want to read a series of photos which are from camera roll and put them in a photo slide to show them one by one.
例如,我想阅读一系列来自相机胶卷的照片,并将它们放在照片幻灯片中,逐一显示。 How can I access these photos without UIImagePickerController?
如何在没有UIImagePickerController的情况下访问这些照片?
You can access photo library using Photos framework(for iOS 8+). 您可以使用Photos框架(适用于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.
在AAPLRootListViewController的代码中,如果使用awakeFromNib方法,您可以看到如何创建PHFetchResult对象以检索特定的照片数据。 Then, in AAPLAssetGridViewController, PHAsset objects(from PHFetchResult) are used for retrieving actual image data.
然后,在AAPLAssetGridViewController中,PHAsset对象(来自PHFetchResult)用于检索实际图像数据。 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. 代码是用Objective-C而不是Swift编写的,但你可以使用Swift做同样的事情。 Ask questions if any.
提问,如果有的话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.