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
1720049562675.png

2 Click again on the first item to access frmFilterPage

Equipos = Teams
1720049630755.png

3 Crash on B4I
1720049654263.png


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
Application_Start
Device locale: es
Found 161 strings.
*** : B4XPage_Foreground
*** mainpage: B4XPage_Created
Application_Active
*** mainpage: B4XPage_Appear [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
Found 161 strings.
Found 161 strings.
Class (b4i_httpjob) instance released.
Class (b4i_httpjob) instance released.
*** frmxfilter: B4XPage_Created [mainpage]
Error occurred on line: 174 (AS_TabMenuAdvanced)
Target is null. Method called: _initialize:::
Stack Trace: (
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 540460
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 1582812
PasSportsAr Handball +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 160
PasSportsAr Handball -[B4ICustomViewWrapper AfterDesignerScript] + 1468
PasSportsAr Handball -[B4ILayoutBuilder loadLayout:::] + 1992
PasSportsAr Handball -[B4IPanelWrapper LoadLayout::] + 176
PasSportsAr Handball -[B4XViewWrapper LoadLayout::] + 80
PasSportsAr Handball -[ResumableSub_frmfilterpage_B4XPage_Created resume::] + 496
PasSportsAr Handball -[b4i_frmfilterpage _b4xpage_created::] + 412
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr Handball +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr Handball -[B4ICommon CallSubDebug4::::] + 832
PasSportsAr Handball -[B4ICommon CallSubDebug2::::] + 272
PasSportsAr Handball -[b4i_b4xpagesmanager _createpageifneeded::] + 888
PasSportsAr Handball -[b4i_b4xpagesmanager _showpage::] + 636
PasSportsAr Handball -[b4i_b4xpages _showpage:] + 388
PasSportsAr Handball -[ResumableSub_b4xmainpage_btnTabMenu_TabClick resume::] + 4048
PasSportsAr Handball -[b4i_b4xmainpage _btntabmenu_tabclick::] + 404
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr Handball +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr Handball -[B4IShell runMethod:] + 420
PasSportsAr Handball -[B4IShell raiseEventImpl:method:args::] + 1968
PasSportsAr Handball -[B4IShellBI raiseEvent:event:params:] + 1360
PasSportsAr Handball -[B4ICommon CallSub4::::] + 240
PasSportsAr Handball -[B4ICommon CallSub2::::] + 272
PasSportsAr Handball -[b4i_as_tabmenuadvanced _tabclickevent::] + 824
PasSportsAr Handball -[b4i_as_tabmenuadvanced _tabclick:::] + 3960
PasSportsAr Handball -[b4i_as_tabmenuadvanced _xpnl_tab_click:] + 436
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr Handball +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr Handball -[B4IShell runMethod:] + 420
PasSportsAr Handball -[B4IShell raiseEventImpl:method:args::] + 1968
PasSportsAr Handball -[B4IShellBI raiseEvent:event:params:] + 1360
PasSportsAr Handball __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 8508
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 15828
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 75172
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 354064
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 342292
CoreFoundation CFRunLoopRunSpecific + 608
GraphicsServices GSEventRunModal + 164
UIKitCore 1741FA37-4E53-371E-8DAE-D611AAB0043D + 4237580
UIKitCore UIApplicationMain + 340
PasSportsAr Handball main + 100
dyld 71846EAC-EE65-3697-BF7D-790B6A07DCDB + 249420
)
 

Attachments

  • 1720049589923.png
    1720049589923.png
    18.7 KB · Views: 67
  • AS TabMenuAdvanced Example.zip
    451.6 KB · Views: 91
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

Copying updated assets files (1)
Application_Start
Device locale: es
Found 161 strings.
*** : B4XPage_Foreground
*** mainpage: B4XPage_Created
Found 161 strings.
Found 161 strings.
Application_Active
*** mainpage: B4XPage_Appear [mainpage]
*** mainpage: B4XPage_Resize [mainpage]
Class (b4i_httpjob) instance released.
Class (b4i_httpjob) instance released.
*** frmxfilter: B4XPage_Created [mainpage]
Error occurred on line: 53 (B4XComboBox)
Target is null. Method called: _initialize:::

Stack Trace: (
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 540460
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 1582812
PasSportsAr HB +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 160
PasSportsAr HB -[B4ICustomViewWrapper AfterDesignerScript] + 1468
PasSportsAr HB -[B4ILayoutBuilder loadLayout:::] + 1992
PasSportsAr HB -[B4IPanelWrapper LoadLayout::] + 176
PasSportsAr HB -[B4XViewWrapper LoadLayout::] + 80
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr HB +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr HB -[B4IShell runMethod:] + 420
PasSportsAr HB -[B4IShell raiseEventImpl:method:args::] + 1968
PasSportsAr HB -[B4IShellBI raiseEvent:event:params:] + 1360
PasSportsAr HB -[b4i_frmfilterpage _b4xpage_created::] + 360
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr HB +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr HB -[B4ICommon CallSubDebug4::::] + 832
PasSportsAr HB -[B4ICommon CallSubDebug2::::] + 272
PasSportsAr HB -[b4i_b4xpagesmanager _createpageifneeded::] + 888
PasSportsAr HB -[b4i_b4xpagesmanager _showpage::] + 636
PasSportsAr HB -[b4i_b4xpages _showpage:] + 388
PasSportsAr HB -[ResumableSub_b4xmainpage_btnTabMenu_TabClick resume::] + 1672
PasSportsAr HB -[b4i_b4xmainpage _btntabmenu_tabclick::] + 404
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr HB +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr HB -[B4IShell runMethod:] + 420
PasSportsAr HB -[B4IShell raiseEventImpl:method:args::] + 1968
PasSportsAr HB -[B4IShellBI raiseEvent:event:params:] + 1360
PasSportsAr HB -[B4ICommon CallSub4::::] + 240
PasSportsAr HB -[B4ICommon CallSub2::::] + 272
PasSportsAr HB -[b4i_as_tabmenuadvanced _tabclickevent::] + 824
PasSportsAr HB -[b4i_as_tabmenuadvanced _tabclick:::] + 3960
PasSportsAr HB -[b4i_as_tabmenuadvanced _xpnl_tab_click:] + 436
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 133140
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 129120
PasSportsAr HB +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
PasSportsAr HB -[B4IShell runMethod:] + 420
PasSportsAr HB -[B4IShell raiseEventImpl:method:args::] + 1968
PasSportsAr HB -[B4IShellBI raiseEvent:event:params:] + 1360
PasSportsAr HB __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 8508
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 15828
libdispatch.dylib 81D355DF-266A-3010-BAB8-113B76A206C1 + 75172
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 354064
CoreFoundation 00E76A98-210C-3CB5-930B-F236807FF24C + 342292
CoreFoundation CFRunLoopRunSpecific + 608
GraphicsServices GSEventRunModal + 164
UIKitCore 1741FA37-4E53-371E-8DAE-D611AAB0043D + 4237580
UIKitCore UIApplicationMain + 340
PasSportsAr HB main + 100
dyld 71846EAC-EE65-3697-BF7D-790B6A07DCDB + 249420
)
 
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
Top