Search code examples
iosswiftphassetphphotolibrary

How to insert a newly created PHAsset at a specific position in camera roll?


Is it possible to insert a new PHAsset to an appointed index in the camera roll?

I tried following:

let cam_req = PHAssetCollectionChangeRequest(for: camera_roll)
cam_req?.insertAssets([asset] as NSArray, at: IndexSet(integer: pos))

doesn't work.


Solution

  • The Camera Roll is like a stack. It's sorted by import date. There is no way to change the order or to insert a photo/video at a specific position. If you want to do that you have to create a custom user album. Custom user albums contain references to the originals in the Camera Roll and can be reordered.