iOS Question XCode 11 & StatusBar

Semen Matusovskiy

Well-Known Member
Licensed User
I tried to replace XCode 10.3 to XCode 11.
No problems with compilation, an app even works due to try/catch, but I see error in log:

<B4IExceptionWrapper: Error Domain=caught_exception Code=0 "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." UserInfo={NSLocalizedDescription=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.}>

Yes, there are changes in API. But I set #MinVersion : 10.2, so (theoretically) the compiled code should be the same as in XCode 10. What's wrong ?
 

Semen Matusovskiy

Well-Known Member
Licensed User
I use Status Bar in one common subroutine only (to change color and/or to hide / show)
B4X:
        nativeObjectInstance = dataCommon.applicationInstance
        nativeObjectInstance.GetField ("statusBar").SetField ("backgroundColor", nativeObjectInstance.ColorToUIColor (intColorStatusBarBackground))
        nativeObjectInstance.RunMethod ("setStatusBarHidden:animated:", Array (Not (booleanShowStatusBar), False))

I looked suggestions on stackoverflow, but did not find something easy and correct.
Unlike to get UIStatusBarManager from Page is simple, this object does not offer status bar view or something like this.
So a logic of Apple developers is unclear for me.

Meanwhile UINavigationBarAppearance looks enough interesting. But I did not try, because I use SlideMenu also.

Any ideas ? XCode 10 works yet, but not for a long time.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
Looks like Apple doesn't want to allow apps to access the status bar.
Agree.
See the answer here for a possible solution: https://stackoverflow.com/a/57394751/971547
Very doubt that Apple wants this way. It looks that there is no statusbar view at all.

StatusBarManager allows to get statusBarHidden, statusBarStyle and statusBarFrame only.
As I understood, two actions are legal only : to show/hide status bar and to change light/dark theme.
In my case this is enough (due to exotic design of IPhone X/XI, I used transparent status bars only).

If I understood correctly, we must "subclass" view controller. Should be simple in XCode (due to wizards).
But to write "implementation" and to pass variables from main program is not simple (at least for me).
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
It seems to me I fixed a problem

I wrote a subroutine ShowPageEx, which accepts some parameters, first of all, status bar style and show/hide status bar. It's not possible to set background/foreground colors for status bar, because Apple removed statusbar view as it is.

Theoretically should work in IOS 7+ (I tested in IOS 13 only).
 

Attachments

  • statusBar.zip
    3.5 KB · Views: 459
Last edited:
Upvote 0
Top