iOS Question Multiple Pages Example and SideMenuController

ykucuk

Well-Known Member
Licensed User
Longtime User
Hello,

I need to add SideMenuController in Page1Module (after user passed login screen) . I got error. My code is bellow

B4X:
Sub Process_Globals
Private pg As Page
Dim sm As SideMenuController
End Sub

Public Sub Show
If pg.IsInitialized = False Then
pg.Initialize("pg")
pg.RootPanel.LoadLayout("Page1Layout")
pg.HideBackButton = True'<-- don't want to allow the user to return to the login screen
Dim lp As Page
lp.Initialize("lp")
lp.RootPanel.Color = Colors.Red
End If

sm.Initialize(lp, Main.NavControl,Null) ' ERROR LINE
Main.App.KeyController = sm
Main.NavControl.ShowPage(pg)
End Sub

Given error is :
B4X:
 adding a root view controller <B4INavigationController: 0x7d105800> as a child of view controller:<MMDrawerController: 0x7bf317e0>
 

tamayo461

Member
Licensed User
Longtime User
Hi @Erel, I have 3 pages in my app with slideMenu, how do I get back to the homepage?

On page 2 and 3 I have:

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 smc As SideMenuController
 
    Dim pg As Page
    Private btnMain As Button
    Private btnPage3 As Button
End Sub


Public Sub Show
    If Not(pg.IsInitialized) Then
        pg.Initialize("pg")
        pg.RootPanel.LoadLayout("page2")
    End If
    Main.NavControl.ShowPage(pg)
 
    'create a new navigation controller 
    Dim nc As NavigationController
    nc.Initialize("nc")
    NavControl = nc     
    Dim lp As Page
    lp.Initialize("lp") 
    lp.RootPanel.LoadLayout("slideMenu")
    smc.Initialize(lp, nc, Null) 
    App.KeyController = smc
    nc.ShowPage(pg)
    pg.TopLeftButtons = Array(smc.CreateBarButton("left"))
    Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(Colors.RGB(69,179,175))))
 
End Sub

Sub pg_BarButtonClick (Tag As String)
    Select Tag
        Case "left"
            smc.OpenLeftMenu

    End Select
End Sub

Sub pg_Click
    smc.OpenLeftMenu
End Sub
 
Upvote 0
Top