iOS Question Error with xui.MsgboxAsync("text", "title") with B4XPages.ClosePage(Me), page does not close

Lucas Siqueira

Active Member
Licensed User
Longtime User
When I display a message with xui.MsgboxAsync("text", "title") and then immediately order to close the page with B4XPages.ClosePage(Me) , on Android it works correctly, but on IOS it does not close the page, and when I click a button that I created and has the command to close the page, nothing happens.

If you try to click on the back button, before clicking on save the page closes correctly, the problem only happens when you display a message and close the page.

All logs appear. but it seems that the command to close the page is not executed.

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
End Sub

Public Sub Initialize As Object
    Return Me
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Cadastro")
End Sub

Private Sub lb_salvar_Click
    Log("lb_salvar_Click 1")
    xui.MsgboxAsync("TESTE","ATENÇÃO")
    B4XPages.ClosePage(Me)
    Log("lb_salvar_Click 2")
End Sub

Private Sub lb_voltar_Click
    Log("lb_voltar_Click 1")
    B4XPages.ClosePage(Me)
    Log("lb_voltar_Click 2")
End Sub
 

Attachments

  • WhatsApp Image 2022-10-11 at 22.30.31 (1).jpeg
    WhatsApp Image 2022-10-11 at 22.30.31 (1).jpeg
    41.7 KB · Views: 169
  • WhatsApp Image 2022-10-11 at 22.30.31.jpeg
    WhatsApp Image 2022-10-11 at 22.30.31.jpeg
    25.1 KB · Views: 182
  • TESTE2.zip
    127.9 KB · Views: 166

Lucas Siqueira

Active Member
Licensed User
Longtime User
When I display a message with xui.MsgboxAsync("text", "title") and then immediately order to close the page with B4XPages.ClosePage(Me) , on Android it works correctly, but on IOS it does not close the page, and when I click a button that I created and has the command to close the page, nothing happens.

If you try to click on the back button, before clicking on save the page closes correctly, the problem only happens when you display a message and close the page.

All logs appear. but it seems that the command to close the page is not executed.

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
End Sub

Public Sub Initialize As Object
    Return Me
End Sub

Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Cadastro")
End Sub

Private Sub lb_salvar_Click
    Log("lb_salvar_Click 1")
    xui.MsgboxAsync("TESTE","ATENÇÃO")
    B4XPages.ClosePage(Me)
    Log("lb_salvar_Click 2")
End Sub

Private Sub lb_voltar_Click
    Log("lb_voltar_Click 1")
    B4XPages.ClosePage(Me)
    Log("lb_voltar_Click 2")
End Sub


if you use Msgbox("TEST","ATTENTION")
instead of xui.MsgboxAsync("TEST","ATTENTION")


Why does it happen?
 
Upvote 0

bobbruns

Member
Licensed User
Longtime User
I had the same problem.
solved it this way:
insert sleep:
#if b4i
sleep(500)
#end if
 
Upvote 0

bobbruns

Member
Licensed User
Longtime User
Is this problem more pronounced on newer iPhones? It may be, sometimes works without the sleep on iPhone SE second generation. iPhone 12 seems to always require this. It ALWAYS works without it on Android, all models. I do not know why this works. It might have to do with layout loading time??????
 
Last edited:
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
if you use Msgbox("TEST","ATTENTION")
instead of xui.MsgboxAsync("TEST","ATTENTION")


Why does it happen?
@Erel is there any way to adjust for this to work well with xui.MsgboxAsync on IOS?


the idea of using xui is to have a single code, or at least to facilitate cross-platform development, it is not so elegant to use
#if b4a
#else if b4i
#else if b4j
#end if
, I know this would work, but the XUI class came to work around these details
 
Upvote 0

Lucas Siqueira

Active Member
Licensed User
Longtime User
Movido para o fórum de perguntas.

O que você está tentando fazer? Deseja mostrar uma mensagem antes que a página seja fechada? Em seguida, você deve aguardar o fechamento da caixa de diálogo. Caso contrário, você deve mostrar a mensagem após a próxima página aparecer.

Moved to the questions forum.

What are you trying to do? Do you want to show a message before the page is closed? Then you should wait for the dialog to close. Otherwise you should show the message after the next page appears.


I just want to display the message
and close the page

using xui.MsgboxAsync
on android it works normally.
on ios the page does not close, unless you put a sleep(400) and then close the page.

using msgbox
on ios it works normally.




i would like on ios the xui.MsgboxAsync command to behave the same as msgbox...

but it seems that the system is stuck and cannot close the page if you use xui.MsgboxAsync and then B4XPages.ClosePage(Me)
 
Upvote 0

bobbruns

Member
Licensed User
Longtime User
Two comments:
1. The user manual indicates that what you are using Lucas should work. It does not.
2. Using the "Wait for object" will work, but requires more keystrokes than the albeit kludgy "sleep(500)."

Also the message box is not always called, even when the page switch needs to be:
In my case, the message box is only called when the user needs to be notified of something unusual, which may be (is) less than 2% (!) of the time. I do not want to call it 98% of the time, so I would need an "If/then/endif."

I have implemented the kludge. My app has 21 pages so I did this to save time. Things seem to be working fine. The delay seems a great workaround for the correct If/then/endif and "wait for object." For me, this occurs on about eight out of the 21 page transitions. I left the others stet and B4x pages works flawlessly on both Android and Apple platforms.
 
Last edited:
Upvote 0
Top