1. Black Friday Sale - 50% off

    B4A Standard for $29 instead of $59!
    Buy Now
    Dismiss Notice

iOS Question Make dialog visible

Discussion in 'iOS Questions' started by asubias, Feb 28, 2019.

Tags:
  1. asubias

    asubias Member Licensed User

    Hello.
    I made a B4XDialog that contains a DateTime Label. To change it I decided to make a DateTimeDialog based on this https://www.b4x.com/android/forum/threads/date-picker-snippet.84098/

    My problem is if i show another dialog the first one closes (that not happens on B4a).
    I tried reshowing the dialog but the wait for no longer works and I think i still having the older dialog in background.

    Is there any way to make visible again? The dialog.Visible is read only and Base.Visible returns True...

    Thank you in advance.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why not use the built-in B4XDateTemplate?

    Full example:
    Code:
    Sub Process_Globals
       
    Public App As Application
       
    Public NavControl As NavigationController
       
    Private Page1 As Page
       
    Private Dialog As B4XDialog
       
    Private DateTemplate As B4XDateTemplate
       
    Private xui As XUI
       
    Private CustomDialogPanel As B4XView
    End Sub

    Private Sub Application_Start (Nav As NavigationController)
       NavControl = Nav
       Page1.Initialize(
    "Page1")
       Page1.Title = 
    "Page 1"
       Page1.RootPanel.LoadLayout(
    "1")
       NavControl.ShowPage(Page1)
       DateTemplate.Initialize
       Dialog.Initialize(Page1.RootPanel)
       Dialog.Title = 
    "B4i"
       CustomDialogPanel = xui.CreatePanel(
    "")
       
    Dim btn As Button
       btn.Initialize(
    "btn", btn.STYLE_SYSTEM)
       btn.Text = 
    "Click to select date"
       CustomDialogPanel.SetLayoutAnimated(
    000300dip300dip)
       CustomDialogPanel.AddView(btn, 
    20dip20dip200dip100dip)
    End Sub

    Sub Page1_Click
       ShowFirstDialog
    End Sub

    Sub ShowFirstDialog
       
    Wait For (Dialog.ShowCustom(CustomDialogPanel, "OK""""")) Complete (Result As Int)
       
    If Result = xui.DialogResponse_Positive Then
           
    Dim date As Long = CustomDialogPanel.Tag
           Page1.Title = 
    DateTime.Date(date)
       
    End If
    End Sub

    Sub btn_Click
       Dialog.Close(xui.DialogResponse_Cancel)
       
    Do While Dialog.Visible
           Sleep(
    30)
       
    Loop
       
    Wait For (Dialog.ShowTemplate(DateTemplate, "OK""""")) Complete (Result As Int)
       CustomDialogPanel.Tag = DateTemplate.Date
       CustomDialogPanel.GetView(
    0).Text = DateTime.Date(DateTemplate.Date)
       ShowFirstDialog
    End Sub
     
    asubias likes this.
  3. asubias

    asubias Member Licensed User

    Thanks Erel :)
    Because i need date and time and i like so much the iOS native datepicker desing.

    Looking at your code i understand that there is no way to make visible again a dialog. The only solution is reinvoke show function and call a new wait for?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Yes.
     
    asubias likes this.
  5. asubias

    asubias Member Licensed User

    Ok, thank you Erel.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice