Saving to Photos Album

Special thanks to Greg and Christian.

Here’s a method that works: (See below for comments.)

Public Sub SaveToPhotosAlbum(Extends pPict As Picture)
// IMPORTANT: Must turn on Photos Access in iOS Build Settings Advanced

Declare Sub UIImageWriteToSavedPhotosAlbum Lib “UIKit” _
(img As ptr, target As ptr, sel As ptr, info As ptr)

Var pt As Ptr

pt = pPict.CopyOSHandle(Picture.HandleType.iOSUIImage)
UIImageWriteToSavedPhotosAlbum(pt,Nil,Nil,Nil)

End Sub


Issues:

  1. In Xojo 2020 2.1 Picture.handle returns 000000.
  2. Somewhere in the docs about memory blocks it suggests that one can pass a memory block to a declare. You can, but no picture.
  3. It’s essential to turn on access to Photos in the Advanced tab. If not, boom.
  4. Finally, once I had things working, I discovered that the picture was blank. In my app, I had made the picture but didn’t draw its contents!

Hope this helps.