iOS Question NavigationBar inside TabBarController

narek adonts

Well-Known Member
Licensed User
Longtime User
Hi, I would like to use a navigation bar inside a specific page to be able to show other pages which are not stored inside TabBarController (like a lot of apps are doing like WhatsApp, Viber,... )
Please advise the solution.

Narek
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
See this example:
B4X:
Sub Process_Globals
   Public App As Application
   Private Page1, page2, page3 As Page
   Private tbc As TabBarController
   Dim nav1 As NavigationController
End Sub

Private Sub Application_Start (nav As NavigationController)
   tbc.Initialize("tbc")
   App.KeyController = tbc
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   
   nav1.Initialize("nav1")
   tbc.Pages = Array(Page1, nav1)
   page2.Initialize("page2")
   page2.RootPanel.Color = Colors.Green
   page2.Title = "Page 2"
   page3.Initialize("page3")
   page3.RootPanel.Color = Colors.Red
   page3.Title = "Page 3"
   nav1.ShowPage(page2)
End Sub

Sub Page2_Click
   nav1.ShowPage(page3)
End Sub

upload_2015-2-15_9-20-39.png
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
Thank you. I think this is a feature that almost everybody would be happy to know. Thank you.
But the next issue relating this is that when I am adding NavigationCotroller to TabBarController i am not able to set a TabBarItem to that page to be able to change the font,...
Please advise this solution also.

Thank you
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
See this example:
B4X:
Sub Process_Globals
   Public App As Application
   Private Page1, page2, page3 As Page
   Private tbc As TabBarController
   Dim nav1 As NavigationController
End Sub

Private Sub Application_Start (nav As NavigationController)
   tbc.Initialize("tbc")
   App.KeyController = tbc
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
 
   nav1.Initialize("nav1")
   tbc.Pages = Array(Page1, nav1)
   page2.Initialize("page2")
   page2.RootPanel.Color = Colors.Green
   page2.Title = "Page 2"
   page3.Initialize("page3")
   page3.RootPanel.Color = Colors.Red
   page3.Title = "Page 3"
   nav1.ShowPage(page2)
End Sub

Sub Page2_Click
   nav1.ShowPage(page3)
End Sub

View attachment 32208
See this example:
B4X:
Sub Process_Globals
   Public App As Application
   Private Page1, page2, page3 As Page
   Private tbc As TabBarController
   Dim nav1 As NavigationController
End Sub

Private Sub Application_Start (nav As NavigationController)
   tbc.Initialize("tbc")
   App.KeyController = tbc
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
 
   nav1.Initialize("nav1")
   tbc.Pages = Array(Page1, nav1)
   page2.Initialize("page2")
   page2.RootPanel.Color = Colors.Green
   page2.Title = "Page 2"
   page3.Initialize("page3")
   page3.RootPanel.Color = Colors.Red
   page3.Title = "Page 3"
   nav1.ShowPage(page2)
End Sub

Sub Page2_Click
   nav1.ShowPage(page3)
End Sub

View attachment 32208

i have create a project with this code, but it doesn't show the navbar.

i need a page with a nav bar (page1, page2, page3) and on page 2 a navbar + toolbar (page2A, page2B)

is it possible? can you show me the code, please?

Thanks
 
Upvote 0

jazzzzzzz

Active Member
Licensed User
Longtime User
You can set the navigation controller tab item with this code:
B4X:
Dim p As Page = nav1
Dim tbb As TabBarItem
tbb.Initialize("asldjlaksdj", Null, Null)
p.TabBarItem = tbb
I have the same code in my project which have tabcontrol and nav control at same page,But my issue us that tabBarItem text is not changing to what i set there.Now the tabrBarItem text is coming as the title of the page shown by nav control...Any idea why that happens?
 
Upvote 0
Top