iOS Question Completely remove the data from page once I leave it?

Shay

Well-Known Member
Licensed User
Longtime User
I have strange problem
I am using this code on each code module page:

B4X:
Public Sub Show
    If PG.IsInitialized = False Then
        PG.Initialize("pg")
        PG.RootPanel.LoadLayout("PageX")
        PG.Title = Main.AppTitle
        PG.RootPanel.Color = Colors.RGB (54,54,54)
        PG.HideBackButton = True ' block button back
    End If
    Main.NavControl.ShowPage(PG)

the problem is when I leave the page and come back to it
all the data is still there (can be also CustomListVew with data)

When I am leaving the page I tried even :
B4X:
    PG.RootPanel.RemoveAllViews   
    PG.RootPanel.RemoveViewFromParent
    scvMain.RemoveViewFromParent
    PG.RootPanel.RemoveAllViews
    Main.NavControl.RemoveCurrentPage

but once I enter the page again all my vars (such as PG, scvMain, etc..) are still initialized
(also tried to init them again, did not help)

How do I completely remove the data from page once I leave it?
 

susu

Well-Known Member
Licensed User
Longtime User
Try to move all that "remove" into

Private Sub pg_Disappear
...
End Sub
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I need your help writing this class,
(never wrote class)
I wrote this, but the issue is that it is not recognizing the layout objects, so it crash on first object (such as label)
(also editor is marking all the vars as not initialized)

B4X:
'Class module
Sub Class_Globals
    Public PG As Page
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Layout As String)

    If PG.IsInitialized = False Then
     PG.Initialize("pg")
     PG.RootPanel.LoadLayout(Layout)
     PG.Title = "MyApp"
     PG.HideBackButton = True ' block button back
    End If
    Main.NavControl.ShowPage(PG)
  
End Sub
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
but I have many modules and for each module it has it own layout, so can't I do something generic in the class, or I need class for each page/module?
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
Tried:
I moved all the code from the module to class (Class name NewPage)
from module1 I am writing:
Dim Step3 As NewPage
Step3.Show

on Class it is crashing on:
If PG1.IsInitialized = False Then


 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
ok, I figure it
I changed the subname from "show" to:
Public Sub Initialize
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…