I’m trying to allow the user to save a document on iOS. All seems fine in code, but the picker just isn’t presented (and I don’t get any event, either cancelled or accepted). I have no clue as to how to read console logs on iOS either, should there be something mentioned.
Here’s my code:
Var fTemp As xojo.io.FolderItem=xojo.IO.SpecialFolder.Temporary //Necessary to access the temporary items folder
if fTemp=nil then return
if not fTemp.Exists then fTemp.CreateAsFolder
Var f As new FolderItem(fTemp.Path) //Convert to regular FolderItem
f=f.Child("sans titre"+System.Ticks.ToString+".MyNewDrawing") //Create a dummy file
if f<>nil and DonnéesDuDocument.Enregistrer(f,CDocument.TypeDEnregistrement.Standard) then //Save the document to the file
SélecteurDeDocument=new UIDocumentPickerMBS(UIDocumentPickerMBS.ModeMoveToService,Array(f.NativePath)) 'SélecteurDeDocument is a property of the window (an UIDocumentPickerMBS object), so it doesn't go out of scope
AddHandler SélecteurDeDocument.documentPickerDidPickDocuments,AddressOf DocumentÀEnregistrerChoisi
AddHandler SélecteurDeDocument.documentPickerWasCancelled,AddressOf DocumentÀEnregistrerAnnulé
SélecteurDeDocument.Present
end if
There doesn’t seem to be a LastErrorCode property either. Any way to know what’s going wrong?
When I use this class, my picker is a property of the window also.
My presentation code differs, however:
Dim types() As String
types.append ".TXT"
types.append ".RTF"
Dim asCopy As Boolean = True
picker = New UIPicker(UIPicker.ModeOpen, types, asCopy)
picker.Present
the UIPicker class is derived from UIDocumentPickerMBS, and adds the picked events
You call present on the main thread?
The main thread is free after you call this, so the animation can happen?
SélecteurDeDocument is a property, so it stays in memory long enough?
Thanks.
I’m seeing it’s working when I put the same code in a blank project.
Right. I chose to use AddHandler and avoid a custom class for keeping things together.
Yes.
I’m thinking this is the problem. If I use Timer.CallLater 1000,AddressOf TheMethod, it works. If I reduce the time to 10, it doesn’t. And indeed, the method is called just after/while a modal dialog is being closed.
But I’d find weird iOS can’t cope with showing a dialog after one closes. Is it that limited?
Thank you.