iOS Question B4XPages B4i Orientation

MList

Active Member
Licensed User
Hi all,
The next problem ?
I switched my app to B4x Pages , i am well aware that B4a can't handle different orientations.
But in my B4I module, the orientation switches but just dont show the other layout... so when i turn my iphone from portrait to landscape,
it switches but still has the layout of portrait mode.
B4XPageModul:
Private Sub B4XPage_Created (Root1 As B4XView)
    
        
        
    Root = Root1
    Root.LoadLayout ("Info")
    PLayoutI.Initialize(Root,"N")
    Subs.SetBorderColor(lblFirma)
    Subs.SetBorderColor(lblFirmware)
    Subs.SetBorderColor(lblHardware)
    Subs.SetBorderColor(lblModell)
    Subs.SetBorderColor(lblSeriennummer)
    txtFirma.TextColor = xui.Color_Yellow
    txtHardware.TextColor = xui.Color_Yellow
    txtModell.TextColor = xui.Color_Yellow
    txtSeriennummer.TextColor = xui.Color_Yellow
    txtFirmware.TextColor = xui.Color_Yellow
    InfoClose.SetColorAndBorder(Var.limadarkblue,3dip,xui.Color_White,15dip)
    InfoClose.Text = Language.Text(Var.v,74)
    
End Sub
Private Sub B4XPage_Appear
    InfoText.Text = "Information"
    lblFirma.Text = Language.Text(Var.v,97)
    lblFirmware.Text = "Firmware"
    lblModell.Text = Language.Text(Var.v,96)
    lblHardware.Text = "Hardware"
    lblSeriennummer.Text = Language.Text(Var.v,95)

End Sub

PLayout is putting the Aplication Name,Version and image and a page bar on each page...
PLayout:
'********************************************************************************************************************
' Die Navigationsbar mit den Seiten und oder PgmName und Version wird unten und oder oben auf die B4XPage gesetzt
' Parameter1 B4XPage
' Paremeter2 "A" beides, P nur Page, N nur  Name und Version
'********************************************************************************************************************         

Sub Class_Globals
    Private xui As XUI
    Private pnlparent As Panel
    Private MP As B4XMainPage
    
    Private AnwendungName As B4XView
    Private AnwendungVersion As B4XView
    #if b4a
    Private LimaZeichen As B4XImageView
    #end if
    #if b4i
    Private LimaZeichen As B4XView
    #end if
    Private lima As Bitmap
    
    
    Public BChart As B4XView
    Public BMenu As B4XView
    Public BOnline As B4XView
    Public BWerte As B4XView
    Dim CurrentPageInfo As B4XPageInfo
    Dim CallPage As String
    Private cmbSpeicher As B4XComboBox
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Parent As    B4XView    , Auswahl As String)
    
    pnlparent = Parent
    MP = B4XPages.MainPage
    pnlparent.LoadLayout("Layout")
    
    Subs.SetRoundBorderD(BMenu)
    BMenu.Color = Colors.Transparent
    BMenu.Text = "Menu"
    BMenu.Tag = 1
    
    Subs.SetRoundBorderD(BWerte)
    BWerte.Color = Colors.Transparent
    BWerte.Text = "Data"
    BWerte.Tag = 2
    
    Subs.SetRoundBorderD(BChart)
    BChart.Color = Colors.Transparent
    BChart.Text = "Chart"
    BChart.Tag = 3
    
    Subs.SetRoundBorderD(BOnline)
    BOnline.Color = Colors.Transparent
    BOnline.Text = "Online"
    BOnline.Tag = 4
    #if b4i
    lima = LoadBitmap(File.DirAssets, "logolima-68x60.jpg")
    #end if
    #if b4a
    lima = LoadBitmap(File.DirAssets, "logolima-68x60.jpg")
    #end if
    
    AnwendungName.TextColor = Colors.white
    AnwendungName.Color = Colors.Transparent
    AnwendungName.Text = Var.AnwendungNameStr
    
    AnwendungVersion.Text = Var.AnwendungVersionStr
    AnwendungVersion.TextColor = Colors.White
    
    LimaZeichen.SetBitmap(lima)
'    LimaZeichen.ResizeMode= "FIT"

    
    If Auswahl = "N"  Then
       BMenu.Visible = False
       BChart.Visible = False
       BWerte.Visible = False
       BOnline.Visible = False
        AnwendungName.Visible = True
        AnwendungVersion.Visible = True
      
    End If
    If Auswahl = "P"      Then
        BMenu.Visible = True
        BChart.Visible = True
        BWerte.Visible = True
        BOnline.Visible = True
        AnwendungName.Visible = False
        AnwendungVersion.Visible = False
    End If
    
    BMenu.Color = Var.limadarkblue
    
    If  B4XPages.MainPage.CurrentPage = MP.PWerte Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Var.limadarkblue
        BOnline.Color = Colors.transparent
        BChart.Color = Colors.transparent
    End If
    If  B4XPages.MainPage.CurrentPage = MP.POnline Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Colors.transparent
        BOnline.Color = Var.limadarkblue
        BChart.Color = Colors.transparent
    End If
    If  B4XPages.MainPage.CurrentPage = MP.PChart Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Colors.transparent
        BOnline.Color = Colors.transparent
        BChart.Color = Var.limadarkblue
    End If
    
    
End Sub
Public Sub SetMenuColor
    BMenu.Color = Var.limadarkblue
    Log("Layout")
    If  B4XPages.MainPage.CurrentPage = MP.PWerte Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Var.limadarkblue
        BOnline.Color = Colors.transparent
        BChart.Color = Colors.transparent
    End If
    If  B4XPages.MainPage.CurrentPage = MP.POnline Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Colors.transparent
        BOnline.Color = Var.limadarkblue
        BChart.Color = Colors.transparent
    End If
    If  B4XPages.MainPage.CurrentPage = MP.PChart Then
        BMenu.Color = Colors.transparent
        BWerte.Color = Colors.transparent
        BOnline.Color = Colors.transparent
        BChart.Color = Var.limadarkblue
    End If
End Sub
Private Sub NBB_Click
    Private btn As B4XView
    Private Index As Int
    btn = Sender
    Index = btn.Tag
    If B4XPages.MainPage.CurrentPage <> MP Then
        B4XPages.ClosePage(MP.CurrentPage)
    End If
    
    Select Index
        Case 1
            B4XPages.MainPage.CurrentPage = MP
'            B4XPages.ShowPageAndRemovePreviousPages("MainPage")
            B4XPages.ShowPage("MainPage")
            
        Case 2
            B4XPages.MainPage.CurrentPage = MP.PWerte
'            B4XPages.ShowPageAndRemovePreviousPages("PWerte")
            B4XPages.ShowPage("PWerte")
        Case 3
            B4XPages.MainPage.CurrentPage = MP.PChart
            B4XPages.ShowPage("PChart")
        Case 4
            B4XPages.MainPage.CurrentPage = MP.POnline
'            B4XPages.ShowPageAndRemovePreviousPages("PChart")
            B4XPages.ShowPage("POnline")
    End Select
End Sub


Since Working with Playout the orientation change doesnt work anymore ... What exactly do I have to do to change orientation and dont loose data on map..

Thanks a lot ...
 
Solution
why not? i am using different orientations in my app and everything works fine.
With B4XPages, the orientation must be locked in B4A.

@MList
1. I recommend you to use as few as possible layout variants. They are difficult to maintain. In many cases you can use the designer script instead.
2. When you load multiple layouts to the same container (panel), only the last loaded layout will be tracked for resize events. The solution is to add a transparent panel to the main layout:

1624945092838.png


And load the second layout to this panel:
B4X:
PLayout1.Initialize(Panel1)

MList

Active Member
Licensed User
Hi Erel, you gave me the tip:
Never duplicate code.
You have two options:
1. Implement the buttons layout + code in a class and create a class instance in each of the pages. This is probably the best solution.

2. Implement it wherever you want and move the buttons panel to the current page when the page appears.

So i implemented a class called Layout (see code above) which sets the Programe Name and version and a picture on top of page and buttons on bottom of page.
Like in example ThreePages with Navbar.
In designer script i have a layout "Info" (landscape and portrait) and a layout "Layout" (landscape and portrait)
Class PLayout:
pnlparent = Parent
MP = B4XPages.MainPage
pnlparent.LoadLayout("Layout")
So i load a second Layout ... MainPage had a layout and then it gets the general Page Layout...
B4XMainPage Module:
Root = Root1
Root.LoadLayout ("Info")
PLayoutI.Initialize(Root,"N")

When i now change orientation of device... only the "Layout" changes orientation ... (the Name and Version and buttons)
but the Info Layout which was loaded before does not change orientation.
 
Upvote 0

MList

Active Member
Licensed User
ZiP was to big. I creates a small Test Pgm with 2 Layouts Main and Layout.
Layout changes orientation and Main not... seems to be only the last loaded Layout which reacts..
Can't attach the Test project .zip file, file is to large (583kb???)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
why not? i am using different orientations in my app and everything works fine.
With B4XPages, the orientation must be locked in B4A.

@MList
1. I recommend you to use as few as possible layout variants. They are difficult to maintain. In many cases you can use the designer script instead.
2. When you load multiple layouts to the same container (panel), only the last loaded layout will be tracked for resize events. The solution is to add a transparent panel to the main layout:

1624945092838.png


And load the second layout to this panel:
B4X:
PLayout1.Initialize(Panel1)
 
Upvote 0
Solution
Top