iOS Question TabBar Controller and Multiple Pages (in different modules)

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone, i took a look at this post:
https://www.b4x.com/android/forum/threads/navigationbar-inside-tabbarcontroller.50653/

Where is shown how to switch between pages using the tabcontroller (like whatsapp looks).

But i have a question: if i want to use that controlller, Do I have to write all the pages of my app in ONE module?

There is a way to write the different pages in different modules and use a TabBarController?

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Complete example:

B4X:
'main
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Public tbc As TabBarController
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   tbc.Initialize("tbc")
   Page2Module.CreatePage
   tbc.Pages = Array(Page1, Page2Module.Page2)
   App.KeyController = tbc
End Sub

B4X:
'Code module named Page2Module

Sub Process_Globals
   Public Page2 As Page
End Sub

Public Sub CreatePage
   Page2.Initialize("page2")
   Page2.RootPanel.Color = Colors.Red
   Page2.Title = "Page 2"
End Sub
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Complete example:

B4X:
'main
Sub Process_Globals
   Public App As Application
   Public NavControl As NavigationController
   Private Page1 As Page
   Public tbc As TabBarController
End Sub

Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   tbc.Initialize("tbc")
   Page2Module.CreatePage
   tbc.Pages = Array(Page1, Page2Module.Page2)
   App.KeyController = tbc
End Sub

B4X:
'Code module named Page2Module

Sub Process_Globals
   Public Page2 As Page
End Sub

Public Sub CreatePage
   Page2.Initialize("page2")
   Page2.RootPanel.Color = Colors.Red
   Page2.Title = "Page 2"
End Sub
Very Helpful!
Thanks Erel
 
Upvote 0
Top