iOS Question Navigation Problem - proper layout doesn't load

DickD

Active Member
Licensed User
I have a module that loads 3 layouts in succession. In Summary: Main Module calls PersonalInfoIP. This module loads layout PIMain. Clicking a button in PIMain loads layout PIDesc and clicking a button there loads PIScollView. All of this works just fine until I get to the end of the chain and click to save or cancel and return to the Main module. But in Main when I want to start the PersonalInfoIP module again it does not display the first PIMain layout but instead shows either PIDesc or PersonalInfoIP - whichever one I last cancelled or saved. Why? I have included the pertinent code below.

B4X:
'Main Module
Private Sub Application_Start (Nav As NavigationController)
 NavControl = Nav
 Page1.Initialize("Page1")
 Page1.Title = "Page 1"
 Page1.RootPanel.Color = Colors.White
 Page1.RootPanel.LoadLayout("Main2")
 NavControl.ShowPage(Page1)
...
'When Next button is clicked in Main2 layout
Sub PersInfo_Click
 Page1.ResignFocus
 PersonalInfoIP.Start()
End Sub

'In PersonalInfoIP module
Sub Start
 If pg.IsInitialized = False Then
 pg.Initialize("pg")
 Main.Page1.ResignFocus
 pg.ResignFocus
 pg.RootPanel.LoadLayout("PIMain")
 End If
 Main.NavControl.ShowPage(pg)
End Sub

'When NEXT button is clicked in PIMain
Sub NextLayout_click
 pg.ResignFocus
 pg.RootPanel.LoadLayout("PIDesc")
End Sub

'When Next button is clicked in PIDesc
Sub ScrollLayout_click
 pg.ResignFocus
 pg.RootPanel.LoadLayout("PIScrollView")
 scv1.Panel.LoadLayout("PersonalInfo")
 scv1.ContentHeight = Panel1.Height
 scv1.ContentWidth = scv1.Width
End Sub

'When Save or cancel button is clicked in PIScrollView
Sub Quit_click
 pg.ResignFocus
 Main.show
End Sub

'In Main Module
Sub show
 Page1.RootPanel.LoadLayout("Main2")
 NavControl.ShowPage(Page1)
End Sub
 

DickD

Active Member
Licensed User
Nevermind. I removed the "If pg.isInitilaized = False" statement in the second module to force pg to be redefined to the first layout in the chain.

I always find the answers to these things about 2 minutes after I post the message. I think just finding the right wording to define the problem makes the solution obvious.
 
Upvote 0
Top