iOS Question Statusbar and SafeAreaInsets

yiankos1

Well-Known Member
Licensed User
Longtime User
Hello,

I have encountered a strange behaviour with statusbar and resizing with SafeAreaInsets. I just want to show statusbar and hide navigationbar, so i followed this:

B4X:
Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Dim PagesManager As B4XPagesManager
    PagesManager.Initialize(NavControl)
    
    NavControl.NavigationBarVisible = False
     
    Dim no As NativeObject=NavControl
    no.GetField("interactivePopGestureRecognizer").RunMethod("setDelegate:",Array(Null))
End Sub

In login b4xpage consists of a scrollview and i put inside the the layout:

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    
'    Main.NavControl.NavigationBarVisible = False
    
    Root.LoadLayout("login")
    
    toast.Initialize(Root)
    
    svLogin.Panel.LoadLayout("svLogin")
        
End Sub

Sub B4XPage_Resize (Width As Int, Height As Int)
    Log(misc.IsStatusBarHidden)
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
    'Resize views
    svLogin.Height = Root.Height
    svLogin.ContentWidth = Root.Width
    svLogin.ContentHeight=Max(lblRegister.Top+lblRegister.Height,Root.Height)

End Sub

The result is this:

Green color is the login's layout background color and red is scrollview's backgournd color in order to highlight the problem. At designer navigation bar and toolbar are disabled.

I think that when resizing puts the same height of the statusbar at the bottom.

If i dont resize with safe areas then works normally. If i show navigationbar then behaves normally

Moreover, if i navigate at restore password i have this problem:

Statusbar overlaps the title. If i change app from recent apps and then come back to this, problem is fixed:


In conclusion, I think in both cases statusbar's height is not calculated correctly.

p.s. I tried it only in debug mode
 

yiankos1

Well-Known Member
Licensed User
Longtime User
Goodmorning Erel,

Indeed fixed this issue.

May i ask, why this code:

B4X:
Sub B4XPage_Resize (Width As Int, Height As Int)
    Dim r As Rect = B4XPages.GetNativeParent(Me).SafeAreaInsets
    Root.SetLayoutAnimated(0, r.Left, r.Top, Width - r.Right - r.Left, Height - r.Bottom - r.Top)
End Sub

is not added automatically when we create a new b4xpage?

In which cases we should NOT use this code?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…