iOS Question ToastMessage too short in duration

mdehrnsb

Member
Licensed User
Longtime User
I have been using the HUD ToastMessage but even when LongDuration is set to True, the actual duration is still too short (about 1/2 second). Is there a way to lengthen this?

Any help is appreciated.
 

JanPRO

Well-Known Member
Licensed User
Longtime User
Hi,

B4X:
Private ToastMessagePage As Page ' in Process_Globals sub

Sub ShowToastMessage(Text As String, Duration As Int, aPage As Page)
    ToastMessagePage = aPage
   
    Dim NaObj As NativeObject
    NaObj = NaObj.Initialize("MBProgressHUD").RunMethod("showHUDAddedTo:animated:",Array(aPage.RootPanel,True))
    NaObj.SetField("labelText",Text)
    NaObj.SetField("mode",5)
   
    Dim T As Timer
    T.Initialize("ToastMessage",Duration)
    T.Enabled = True
End Sub

Sub ToastMessage_Tick
    Dim T As Timer = Sender
    T.Enabled = False
    Dim NaObj As NativeObject
    NaObj = NaObj.Initialize("MBProgressHUD").RunMethod("hideHUDForView:animated:",Array(ToastMessagePage.RootPanel,True))
End Sub

Jan
 
Upvote 0

mdehrnsb

Member
Licensed User
Longtime User
JanPRO,

Thank you for the code. I added the code to my system and it worked fine while debugging but when I created a release app, it crashed the app whenever your code launched. Any ideas for a fix or what might be wrong? Could you provide a code snippet that shows the correct way to call it. I'm probably calling it improperly.

Thanks,

Mark
 
Upvote 0
Top