I am using PHPhotoLibrary to access camera roll photos. But it is getting all images, like downloaded images, screenshots, Facebook Image etc. I need images which are clicked by the camera.
Asked
Active
Viewed 300 times
1 Answers
1
I believe that this link may help you:
How to get only images in the camera roll using Photos Framework
Through some experimentation we discovered a hidden property not listed in the documentation (assetSource). Basically you have to do a regular fetch request, then use a predicate to filter the ones from the camera roll. This value should be 3.
Sample code:
//fetch all assets, then sub fetch only the range we need
var assets = PHAsset.fetchAssetsWithMediaType(PHAssetMediaType.Image, options: fetchOptions)
assets.enumerateObjectsUsingBlock { (obj, idx, bool) -> Void in
results.addObject(obj)
}
var cameraRollAssets = results.filteredArrayUsingPredicate(NSPredicate(format: "assetSource == %@", argumentArray: [3]))
results = NSMutableArray(array: cameraRollAssets)

Community
- 1
- 1

George Lee
- 814
- 18
- 34