iOS Question iOS App crash

Sergio Haurat

Active Member
Licensed User
Longtime User
@Alexander Stolte, I have a problem when I want to present the menu with other options in a B4XPage that is not B4XMainPage. The strange thing is that it only happens in B4I.

I also attached in the post, a version of your example that simulates what I do in my application

Below I show you part of the code in B4XMainPage
B4XMainPage:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    'AS_TabMenuAdvanced
    Private btnTabMenu As AS_TabMenuAdvanced
    #If B4I
    Private xpnl_bottom As B4XView
    #End If
End Sub

Private Sub B4XPage_Resize (Width As Int, Height As Int)
#If B4I
    'AS_TabMenuAdvanced
    xpnl_bottom.SetLayoutAnimated(0, 0, Height - B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom,Width,B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom)
    btnTabMenu.mBase.Top = Height - btnTabMenu.mBase.Height - B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom
#End If
End Sub

Private Sub B4XPage_Created (RootView As B4XView)
    #If B4I
    'AS_TabMenuAdvanced
    xpnl_bottom = xui.CreatePanel("")
    Root.AddView(xpnl_bottom, 0, 0, Root.Width, B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom)
    xpnl_bottom.Color = 0xFF202125
    #End If
 
    'AS_TabMenuAdvanced
    btnTabMenu.Clear
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("fed_short"), xui.LoadBitmap(File.DirAssets, "icon_fed.png"), xui.LoadBitmap(File.DirAssets, "icon_fed.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("club_short"), xui.LoadBitmap(File.DirAssets, "icon_club.png"), xui.LoadBitmap(File.DirAssets, "icon_club.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("db_short"), xui.LoadBitmap(File.DirAssets, "icon_save.png"), xui.LoadBitmap(File.DirAssets, "icon_save.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("xlsx_short"), xui.LoadBitmap(File.DirAssets, "icon_xlsx.png"), xui.LoadBitmap(File.DirAssets, "icon_xlsx.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("back_short"), xui.LoadBitmap(File.DirAssets, "icon_previus.png"), xui.LoadBitmap(File.DirAssets, "icon_previus.png"))
    btnTabMenu.GetTab(0).xTab.Tag = "fed"
    btnTabMenu.GetTab(1).xTab.Tag = "club"
    btnTabMenu.GetTab(2).xTab.Tag = "saveToDB"
    btnTabMenu.GetTab(3).xTab.Tag = "saveToFile"
    btnTabMenu.GetTab(btnTabMenu.GetTabs.Size - 1).xTab.Tag = "back"
    btnTabMenu.GetTab(1).xTab.Enabled = False
    btnTabMenu.GetTab(2).xTab.Enabled = False
    btnTabMenu.GetTab(3).xTab.Enabled = False
    btnTabMenu.Refresh
End Sub

If you want, you can see how the application works on Android to understand exactly what I mean in the steps that I now indicate.

1 Click on the first item (makes a .clear of the menu and fills with the sub-menu of the selected item)
BdD Base de datos = Database

2 Click again on the first item to access frmFilterPage

Equipos = Teams

3 Crash on B4I


Android app: https://play.google.com/store/apps/details?id=ar.com.sysprofile.psahb

frmFilterPage:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    'AS_TabMenuAdvanced
    Private btnTabMenu As AS_TabMenuAdvanced
    #If B4I
    Private xpnl_bottom As B4XView
    #End If
End Sub

Private Sub B4XPage_Resize (Width As Int, Height As Int)
#If B4I
    'AS_TabMenuAdvanced
    xpnl_bottom.SetLayoutAnimated(0,0,Height - B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom,Width,B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom)
    btnTabMenu.mBase.Top = Height - btnTabMenu.mBase.Height - B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom
#End If
End Sub

Private Sub B4XPage_Created (RootView As B4XView)
    Root = RootView
    Root.LoadLayout("frmFilter")
    #If B4I
    'AS_TabMenuAdvanced
    xpnl_bottom = xui.CreatePanel("")
    Root.AddView(xpnl_bottom, 0, 0, Root.Width, B4XPages.GetNativeParent(Me).SafeAreaInsets.Bottom)
    xpnl_bottom.Color = 0xFF202125
    #End If

    btnTabMenu.AddTab(mdlFunctions.loc.Localize("fed_short"), xui.LoadBitmap(File.DirAssets, "icon_fed.png"), xui.LoadBitmap(File.DirAssets, "icon_fed.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("club_short"), xui.LoadBitmap(File.DirAssets, "icon_club.png"), xui.LoadBitmap(File.DirAssets, "icon_club.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("xlsx_short"), xui.LoadBitmap(File.DirAssets, "icon_xlsx.png"), xui.LoadBitmap(File.DirAssets, "icon_xlsx.png"))
    btnTabMenu.AddTab(mdlFunctions.loc.Localize("back_short"), xui.LoadBitmap(File.DirAssets, "icon_previus.png"), xui.LoadBitmap(File.DirAssets, "icon_previus.png"))
    btnTabMenu.Refresh
    btnTabMenu.GetTab(0).xTab.Tag = "fed"
    btnTabMenu.GetTab(1).xTab.Tag = "club"
    btnTabMenu.GetTab(2).xTab.Tag = "saveToFile"
    btnTabMenu.GetTab(3).xTab.Tag = "back"
    btnTabMenu.Refresh
End Sub

Error
 

Attachments

  • 1720049589923.png
    18.7 KB · Views: 174
  • AS TabMenuAdvanced Example.zip
    451.6 KB · Views: 236
Last edited:

Sergio Haurat

Active Member
Licensed User
Longtime User
The sample project works for me without errors. Make sure you have the newest version.
The example I shared also works for me. In my original project it doesn't work. The code I wrote above is from the original project. I can't understand why it shows that error as if the component was missing initialization in the B4XPage and it is in the designer, the error is very strange.

Update:
After hours of not being able to find a solution, it occurred to me to go to the B4XMainPage page, which is the only one that worked for me AS TabMenuAdvanced in B4I, open each B4XPage with the designer, delete the object, then copy and paste it from B4XMainPage and it stopped generating that mistake. When I finished the project in B4A, to avoid placing each element in the B4I designer, I copied and pasted between the environments. Obviously something is wrong since now I have the same problem but with B4XComboBox

 
Last edited:
Upvote 0

Sergio Haurat

Active Member
Licensed User
Longtime User
@Alexander Stolte, it's not a problem with your component, it's a problem with any B4XPage, but it only happens with B4I.

*** frmxedituser: B4XPage_Created [mainpage]
Error occurred on line: 467 (AS_TextFieldAdvanced)
Target is null. Method called: _initialize:::

*** frmxfilter: B4XPage_Created [mainpage]
Error occurred on line: 53 (B4XComboBox)
Target is null. Method called: _initialize:::

I thought I was doing the B4XPage forms call incorrectly, it was only initializing and adding a B4XPage page if the user accessed the option, a generic example:

B4X:
Sub Class_Globals
  Dim frm1 As B4XPage1
  Dim frm2 As B4XPage2
End Sub

Private Sub MenuClick(id As Int)
  Select case id
    Case 1
      If Not (frm1.Initialized) Then
        frm1.Initialize
        B4XPages.AddPage("Page1", frm1)
      End If
      B4XPages.Show("Page1")
    Case 2
      If Not (frm2.Initialized) Then
        frm2.Initialize
        B4XPages.AddPage("Page2", frm2)
      End If
      B4XPages.Show("Page2")
  End Select
End Sub

This way, I save device resources if the user uses only 3 of the 10 available B4XPages. On Android it works without problems

Now I changed all the necessary code so that they are always initialized when loading the B4XMainPage page, assuming that possibly iOS needs to have everything loaded, but the same error still occurs.

I don't know if you or @Erel can think of what I might be doing wrong with your experience.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…