iOS Question Something I can't understand when trying to create layout by code

susu

Well-Known Member
Licensed User
Hi guys,

I always create layout of my Android apps by using code only. I'm trying to do the same with B4i.
Here is the routine I'm using:

B4X:
Private Sub Application_Start 
   Initialize pages (Page1, Page2...)
   Call Sub that create Page1 Layout
   Show Page1
End Sub

Private Sub CreatePage1Layout
   Initialize views of Page1
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    Add all views of Page1 into Page1.RootPanel here
End Sub

Private Sub ButtonToOpenPage2_Click
    Call Sub that create Page2 Layout
    Show Page2
End Sub

Private Sub CreatePage2Layout
   Initialize views of Page2
End Sub


Private Sub Page2_Resize(Width As Int, Height As Int)
    Add all views of Page2 into Page2.RootPanel here
End Sub


.......
Is there something wrong? I make test app with 2 pages. I load background by adding an ImageView. It's ok on Page1 but when I move to Page2 and back to Page1 there's no more background. Please find attachment for the code.

Hope you can share your experience. I'm very new to iOS and B4i.

Thank you so much.
 

Attachments

susu

Well-Known Member
Licensed User
I will learn to use Designer script.
Is my routine right?
 

susu

Well-Known Member
Licensed User
Which is better?

1. Load all layouts of all pages in Private Sub Application_Start then show the page when button clicked.

or

2. After users click on button, load layout of next page then show it.

Thanks.
 
Top