Forum Archive

Title Bar and Objc_util

stephen

objc_util update?

Header not meant to be missleading lol..

Good morning fellow pythoneers.. im woking on a posters request and my previouse "fix" wasnt quitewhat Post needs. here is the post to save myself some time explaining.. bern at this one all night..

POST

User also mentions they would rather not Override Present for ui.View. not sure why really.. but by not doing override and "hard" setting the yof PageControl.scrollView we came into issues where if the title_bar i hidden there is a gap 20pt where we set the y value. i went through ALOT of pages on Apple Dev sight and found that some of the class and method calls have moved/changed.. that wasnt fun 😂😅 .. but i did manage to try the following to change StatusBar and fine if it is hidden or not...
i know the StatusBar and Title are not the same but im hopping that they share the same UIControllerwith the Nav View..


Some stuff just wouldnt work and for some reason i could find Fields/Variables that should of helped... and even if i set CGRect or CGPoint it would change the values but did nothing to the live objects... i assume i wasnt using the live views controller.

the method that should have worked i thought was:


[[UIApplication sharedApplication] isStatusBarHidden]

(python)
objc_util.ObjCClass('UIApplication').sharedApplication(). isStatusBarHidden

this would return a boolean but not for current View..

Sorry for the messy post lol tired. and thank you in advance!

JonB

not sure if this is what you want:

objc_util.UIApplication.sharedApplication().statusBar().hidden=True

(or can use setHidden_(True))

stephen

@JonB cannot use that anymore

gives this after crashing Pythonista.


2020-04-03 06:26:39.572008
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.

All i literaly need to do is do a check at runtime inside ui.View class to see if the titlebar is hidden or not. isStatusBarHidden is soposed to be the wy to check but i tjust returns a defaulted False boolean.

cvp

@stephen deprecated

stephen

@cvp lol well any chance anyone knowsthe method to get if itshidden?

stephen

feel like i researched all night for nothin lol

cvp

@stephen said:

any chance anyone knowsthe method to get if itshidden?

I search, let me some time 😀

stephen

@cvp awesome thank you!

cvp

@stephen we are in the right way,I hope but not sure

from objc_util import *
a = ObjCClass('UIApplication').sharedApplication()
for window in a.windows():
    print(window.windowScene().statusBarManager().isStatusBarHidden()) 

Edit: if, in the loop, you add print(window), you will see that the first window is a PA3PythonistaWindow object

Samer

From a bit of searching it seems like prefersStatusBarHidden (source) returns true/false if the view controller is requesting the status bar to be hidden. Not sure if this would work, just thought I would through in what I found.

cvp

@Samer You're perhaps right but the error message got by @stephen is

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.
cvp

@stephen try

from objc_util import *
a = ObjCClass('UIApplication').sharedApplication()
for window in a.windows():
    if 'PA3PythonistaWindow' in str(window._get_objc_classname()):
        #print(dir(window.windowScene().statusBarManager()))
        print(window.windowScene().statusBarManager().statusBarHeight()) 
        print(window.windowScene().statusBarManager().statusBarHidden())
        break 
stephen

@cvp i grabed a list of all the members in UIcontroller.

here

ill check that put u posted asapnthanks!

stephen

@cvp it apears you are in the right place there but i have a feeling that title_bar is a navigation bar cuz no matter what is done it says its false for not hidden.

here is another list of classes and methods but i didnt gather this one

cvp

@stephen the checks are about statusBar, not titleBar, no?

stephen

@cvp no im sorry 😎 i need to check if a mainView has hide_title_bar from present() set to true or False after runtime from inside the customeView Class body

stephen

@Samer said:

From a bit of searching it seems like prefersStatusBarHidden (source) returns true/false if the view controller is requesting the status bar to be hidden. Not sure if this would work, just thought I would through in what I found.

gave prefersStatusBarHidden a try and doesnt seem to exist within pythonistas UIView environment

cvp

@stephen said:

i need to check if a mainView has hide_title_bar from present()

I guess your problem is for a sheet only, because if full screen,
the height of the ui.View is
either the screen height (hide_title_bar=True)
either 70 pixels less (hide_title_bar=False).

stephen

@cvp Fullscreen objc scrollview
Normaly Yes but this is tied into this lol and that titlebar is givin me a run for my lunch.. we have done the following so far..
- walked SuperViewTree
- Iterated over objc UIApplicstion
- Checked layout for all inset values.

every time i feel close... nothin lol i even think i found a nav view with y set to 70.. but nothingbwith height 70..