Not sure if this is really possible but I don't know if I have the right things here. It seems possible from reading around that despite what is set in the info.plist that one can programmatically hide the status bar (time, battery etc).
I thought someone had already tried this but I couldn't find anything in the forum. Sorry for wasting time if it was already discussed I just couldn't find it.
I've tried this, doesn't work:
from objc_util import * import ui #try to get a true full screen without any iOS status bar. v = ui.View() ObjCInstance(v).prefersStatusBarHidden_ = True #likely wrong but i'm not sure... v.present(hide_title_bar=True) shared_application = ObjCClass('UIApplication').sharedApplication() shared_application.setStatusBarHidden_ = True
shared_application.setStatusBarHidden_is a function not a variable. Try
The same goes for
As to whether or not it will work, I don't know, I would need to do further research.
Thanks @Cethric . Though...if I change to functions I believe the
setStatusBarHidden_(True)is okay. The thing that is not okay is setting
prefersStatusBarHidden_(True)on a view object. The method is not there.
Perhaps my error is that
prefersStatusBarHiddenbelongs to something else?
Anyway it seems this is the way to enable this functionality if it wasn't set in the info.plist (which I believe it isn't for Pythonista).
According to this the above is deprecated in iOS 9. Apparently using
UIViewControlleris what is needed. This shows up as a method in the console autocomplete but when trying to actually call it I get the error that there is no such method. ???
>>> a = ObjCClass('UIViewController').alloc().init() >>> a.prefersStatusBarHidden(True) Traceback (most recent call last): File "<string>", line 1, in <module> File "/var/containers/Bundle/Application/E466E17B-54D9-45D4-BC0D-A2A4CFD1F40C/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/objc_util.py", line 796, in __call__ method_name, kwarg_order = resolve_instance_method(obj, self.name, args, kwargs) File "/var/containers/Bundle/Application/E466E17B-54D9-45D4-BC0D-A2A4CFD1F40C/Pythonista3.app/Frameworks/PythonistaKit3.framework/pylib/site-packages/objc_util.py", line 403, in resolve_instance_method raise AttributeError('No method found for %s' % (name,)) AttributeError: No method found for prefersStatusBarHidden
ui2(https://github.com/controversial/ui2) supports this. Use:
import ui2 ui2.statusbar.hide()
For completeness, ui2 works, as does
and, if you wanted to go the prefersStatusBarHidden route:
from objc_hacks import swizzle from objc_util import ObjCClass, UIApplication import objc_util # for hideStatusBar storage try: objc_util.hideStatusBar except AttributeError: objc_util.hideStatusBar=False def togglestatusbar(): objc_util.hideStatusBar=not objc_util.hideStatusBar UIApplication.sharedApplication().\ _rootViewControllers().setNeedsStatusBarAppearanceUpdate() def prefersStatusBarHidden(obj,cmd): return objc_util.hideStatusBar swizzle.swizzle( ObjCClass('PASlidingContainerViewController'), 'prefersStatusBarHidden', prefersStatusBarHidden) UIApplication.sharedApplication().\ _rootViewControllers().\ setNeedsStatusBarAppearanceUpdate() togglestatusbar()
Note that method belongs to the ViewController, so you have to find a view controller and swizzle it.