iOS Question iOS statusBar object replaced (?) - runtime error

Mike1970

Well-Known Member
Licensed User
Hi, in this thread i was worried because a project I was coding month before stopped working with no changes.
After some tips from the guys who helped me, i discovered that this istuction does not work anymore, and causes the crash of the app (in my particular case no log message was dispalyed).

B4X:
Dim no As NativeObject = App
no.GetField("statusBar").SetField("backgroundColor", no.ColorToUIColor(0xFFBB4B4B))
The error is:
Rich (BB code):
App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.
Anyone knows how to achieve the same result now (Change the color of the statusbar)?

Edit:
Also the navigationBar behaves strange..

B4X:
Dim no As NativeObject = Main.NavControl
no.GetField("navigationBar").SetField("prefersLargeTitles", True)
no.GetField("navigationBar").SetField("translucent", False)
no = ContactListPg
no.GetField("navigationItem").SetField("largeTitleDisplayMode", 1) 'always
Result:
IMG_0533.jpg

Edit2:
if i remove this line the navigationbar show "correctly", but in standard mode obviouslly not with Large title
B4X:
no.GetField("navigationBar").SetField("prefersLargeTitles", True)
 
Last edited:

so27

Active Member
Licensed User
I have the same question. Just tried to create an update and got the same error message. Where can I find the statusBarManager object?
 

so27

Active Member
Licensed User
Must have been since yesterday or the day before, because before that I could easily create an update.
 

Mike1970

Well-Known Member
Licensed User
Must have been since yesterday or the day before, because before that I could easily create an update.
oh ok, so I choosen the right moment to take back the project ahaha, and discover that the things just changed under my feet
 

so27

Active Member
Licensed User
I just commented out the code. The app then starts and the StatusBar has the same color as the NavigationBar. I use the following code for the NavigationBar.

Navbar:
    Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(0xFF4BAE4F))) ' Navbar
But ... where can I find this statusBarManager object?
 

Mike1970

Well-Known Member
Licensed User
I just commented out the code. The app then starts and the StatusBar has the same color as the NavigationBar. I use the following code for the NavigationBar.

Navbar:
    Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(0xFF4BAE4F))) ' Navbar
But ... where can I find this statusBarManager object?
Actually i tried this line in my code and the navigation bar stays black (I don't know why) Take a look at my edit in the first post.
Have you something similar?
 

so27

Active Member
Licensed User
I only use:

B4X:
    ' Because of status bar (color)
    #PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
and in "Application_Start":

B4X:
 Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(0xFF4BAE4F))) ' Navbar
 

Mike1970

Well-Known Member
Licensed User
I only use:

B4X:
    ' Because of status bar (color)
    #PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
and in "Application_Start":

B4X:
 Dim no As NativeObject = NavControl
    no.GetField("navigationBar").RunMethod("setBarTintColor:", Array(no.ColorToUIColor(0xFF4BAE4F))) ' Navbar
Oh ok, i used also large titles.

So, now the problems are:
- Find how to change color ONLY of the statusbar
- Find how to display large title correctly
 

so27

Active Member
Licensed User
To change the color ONLY of the StatusBar, I'm currently also overwhelmed.
 

Computersmith64

Well-Known Member
Licensed User
Your existing code should still work on devices not running iOS 13 - but for iOS 13+ you need to use the StatusBarManager. This thread might help you. Also, Google is a good place to find more info about these kinds of issues because they generally aren't specific to B4X.

- Colin.
 

Mike1970

Well-Known Member
Licensed User
Your existing code should still work on devices not running iOS 13 - but for iOS 13+ you need to use the StatusBarManager. This thread might help you. Also, Google is a good place to find more info about these kinds of issues because they generally aren't specific to B4X.

- Colin.
thanks Colin, now I check it out
 

Mike1970

Well-Known Member
Licensed User
Your existing code should still work on devices not running iOS 13 - but for iOS 13+ you need to use the StatusBarManager. This thread might help you. Also, Google is a good place to find more info about these kinds of issues because they generally aren't specific to B4X.

- Colin.
ok i saw it. in this way is possibile only change the text color (black or white), in a weird way..
 
Last edited:
Top