iOS Question Side Menu plus TabStrip

aaronk

Well-Known Member
Licensed User
Longtime User
Hi,

I am using the iSideMenu - https://www.b4x.com/android/forum/threads/isidemenu.46914/#post-290466

The above is working fine, but based on the example from the above page, I am trying to add a TabStrip to Panel1.

I used the designer and added the CustomView to add the TabStrip, but when I run the app is crashes and shows the following error:

B4X:
Copying updated assets files (1)
Application_Start
SignalHandler 11
Error occurred on line: 41 (Main)
Signal - 11
Stack Trace: (
    "0   B4i Example          SignalHandler + 120",
    "1   libsystem_platform.dylib            0x0000000183460b48 _sigtramp + 36",
    "2   UIKit                <redacted> + 228",
    "3   UIKit                <redacted> + 148",
    "4   B4i Example          -[XLButtonBarView updateSelectedBarPositionWithAnimation:swipeDirection:pagerScroll:] + 192",
    "5   B4i Example          -[XLButtonBarPagerTabStripViewController viewWillLayoutSubviews] + 308",
    "6   UIKit                <redacted> + 1100",
    "7   QuartzCore           <redacted> + 184",
    "8   QuartzCore           <redacted> + 324",
    "9   QuartzCore           <redacted> + 320"
)

I have attached the test project I used for testing. Maybe I am doing something wrong?

My aim is to allow the side menu to open (which is working) but then I also want to add a section on the page (not the side menu) to scroll across as well.

Soon as I add the TabStrip the app crashes. Removing the TabStrip the app runs fine.
 

Attachments

  • test.zip
    2.7 KB · Views: 236

aaronk

Well-Known Member
Licensed User
Longtime User
Are you adding at least one page to TabStrip? Otherwise it will crash.
I think I am adding it?

I just changed the Application_Start code to:

Layout file '1' will add the TabStrip1 to the page.

Still crashes.. guess I didn't add it correctly?

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private smc As SideMenuController
    Private TabStrip1 As TabStrip
    Private TabPages As List
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'create a new navigation controller  
    Dim nc As NavigationController
    nc.Initialize("nc")
    NavControl = nc
    TabPages.Initialize
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    Page1.RootPanel.LoadLayout("1")
   
    Dim TabPage1 As Page
    TabPage1.Initialize("TabPage1")
    TabPage1.RootPanel.LoadLayout("Tab1")
    TabPage1.Title = "Tab 1 Title"
    TabPages.Add(TabPage1)
    TabStrip1.SetPages(TabPages)
   
    Dim lp As Page
    lp.Initialize("lp")
    lp.RootPanel.Color = Colors.Red
    lp.RootPanel.LoadLayout("1")
    Dim rp As Page
    rp.Initialize("rp")
    rp.RootPanel.Color = Colors.Green
    rp.RootPanel.LoadLayout("1")
    smc.Initialize(lp, nc, rp)
    App.KeyController = smc
    nc.ShowPage(Page1)
    Page1.TopRightButtons = Array(smc.CreateBarButton("right"))
    Page1.TopLeftButtons = Array(smc.CreateBarButton("left"))
End Sub

B4X:
Application_Start
Application_Active
SignalHandler 11
Error occurred on line: 80 (Main)
Signal - 11
Stack Trace: (
    "0   B4i Example          SignalHandler + 120",
    "1   libsystem_platform.dylib            0x0000000183460b48 _sigtramp + 36",
    "2   UIKit                <redacted> + 228",
    "3   UIKit                <redacted> + 148",
    "4   B4i Example          -[XLButtonBarView updateSelectedBarPositionWithAnimation:swipeDirection:pagerScroll:] + 192",
    "5   B4i Example          -[XLButtonBarPagerTabStripViewController viewWillLayoutSubviews] + 308",
    "6   UIKit                <redacted> + 1100",
    "7   QuartzCore           <redacted> + 184",
    "8   QuartzCore           <redacted> + 324",
    "9   QuartzCore           <redacted> + 320"
)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Your code creates three different TabStrips and only adds a page to one of them.
Each call to LoadLayout("1") will create another TabStrip.

2. The ButtonCell.xip file is missing: https://www.b4x.com/android/forum/threads/tabstrip.80277/#content

This code works:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   'create a new navigation controller   
   Dim nc As NavigationController
   nc.Initialize("nc")
   NavControl = nc
   TabPages.Initialize
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.Blue
   Page1.RootPanel.LoadLayout("1")
   
   
   TabPage1.Initialize("TabPage1")
   TabPage1.RootPanel.LoadLayout("Tab1")
   TabPage1.Title = "Tab 1 Title"
   TabPages.Add(TabPage1)
   TabStrip1.SetPages(TabPages)
'   
   Dim lp As Page
   lp.Initialize("lp")
   lp.RootPanel.Color = Colors.Red
   Dim rp As Page
   rp.Initialize("rp")
   rp.RootPanel.Color = Colors.Green
   smc.Initialize(lp, nc, rp)
   App.KeyController = smc
   nc.ShowPage(Page1)
   Page1.TopRightButtons = Array(smc.CreateBarButton("right"))
   Page1.TopLeftButtons = Array(smc.CreateBarButton("left"))
End Sub
 
Upvote 0

aaronk

Well-Known Member
Licensed User
Longtime User
Thanks heaps, that fixed the issue.

The file ButtonCell.xip was in my original project, but when I created that small test project to see what I was doing wrong, I forgot to copy it over.
 
Upvote 0

Similar Threads

Top