iOS Question XUI timing conflict with b4xpages

bobbruns

Member
Licensed User
Longtime User
This code works on b4a:


back from submit:
Sub sign_up_back_Click
xui.MsgboxAsync("sign up cancelled","'No Touch' Orienteering")
B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub

but on B4i the following error is thrown:
setViewControllers:animated: called on <B4INavigationController 0x103815600> while an existing transition or presentation is occurring; the navigation stack will not be updated.

I added a delay:

back click with delay:

back click with delay:
Sub sign_up_back_Click
xui.MsgboxAsync("sign up cancelled","'No Touch' Orienteering")
    #if b4i
    Sleep(500) '390 is too short! 400 works
    #End If
B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub

the error message is gone
 

William Lancee

Well-Known Member
Licensed User
Longtime User
I don't know why it works in Android and not in iOS. I thought that the next statement caused the problem.

Can you use B4XPages.ShowPage("MainPage") without removing previous pages?
In other words why do you need to remove previous pages? They just sit in the stack, where they don't do any harm.

In any case someone else might have a better idea.
 
Upvote 0

bobbruns

Member
Licensed User
Longtime User
Yes you can, . It is the same as for xui.Msgbox2Async
android diff:
#if b4a
xui.MsgBoxAsync("message","title")
#else if b4i
wait for xui.MsgBoxAsync("message","title")
#end if
B4xpages.ShowPageandRemovePreviousPages("Mainpage")

Should I do it this way? or just add a "wait for" in front of all message boxes so it will run on Apple too?

Wouldn't use of a synchronous message block be better on ios? In other words, never use xui.MsgBoxAsync on iOS.
 
Last edited:
Upvote 0

bobbruns

Member
Licensed User
Longtime User
Yes you can, . It is the same as for xui.Msgbox2Async

I don't know why it works in Android and not in iOS. I thought that the next statement caused the problem.

Can you use B4XPages.ShowPage("MainPage") without removing previous pages?
In other words why do you need to remove previous pages? They just sit in the stack, where they don't do any harm.

In any case someone else might have a better idea.
I have verified that the same behavior is with "showpage". Either way the log error is generated. Also the same behavior is with both debug and compiled versions. Again, only with Apple, Android works fine, no issues. iPhone SE iOS 15.6. Both local builder and hosted builder exhibit identical behavior.. Local builder is Mac mini M1. B4i 8.00. I have spend hours with this issue. The code: sleep(500) seems to be an easy workaround with the fewest keystrokes.
 
Last edited:
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Should I do it this way? or just add a "wait for" in front of all message boxes so it will run on Apple too?
B4X:
Dim sf As Object = xui.MsgboxAsync("Delete file?", "Title")
Wait For (sf) Msgbox_Result (Result As Int)
 
Upvote 0
Top