iOS Question Closing the DatePicker panel

BanditMrP

Member
Licensed User
I've searched and searched and can't find an answer. When using the standard iOS DatePicker, I can get the date chosen in the DatePicker1_ValueChanged sub, but... how do I tell the DatePicker to close the panel that it opens? I can't find a method of doing so in all the options available to the DatePicker view, and all the views found with Root.GetAllViewsRecursive doesn't find any extra items (I've tagged everything, and there's no blank tagged items shown).

How do I close that panel?

Thanks
Ian
 
Solution
B4X:
Private Sub DatePicker1_ValueChanged
    'If not using B4XPages then change to Page1
    Dim pvc As NativeObject = B4XPages.GetNativeParent(Me).As(NativeObject).GetField("presentedViewController")
    If pvc.IsInitialized Then
        pvc.RunMethod("dismissViewControllerAnimated:completion:", Array(True, Null))
    End If
    Log(DateTime.Date(DatePicker1.Ticks))
End Sub

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
Private Sub DatePicker1_ValueChanged
    'If not using B4XPages then change to Page1
    Dim pvc As NativeObject = B4XPages.GetNativeParent(Me).As(NativeObject).GetField("presentedViewController")
    If pvc.IsInitialized Then
        pvc.RunMethod("dismissViewControllerAnimated:completion:", Array(True, Null))
    End If
    Log(DateTime.Date(DatePicker1.Ticks))
End Sub
 
Upvote 0
Solution

BanditMrP

Member
Licensed User
Perfect. Thank You Erel, your help is much appreciated.

I am using B4X Pages (So I can do cross-platform Android and IOS with this app), so no changes were required to the above.

Your help is much appreciated.
 
Upvote 0
Top