UI Orientation Issues...Staying locked
-
I am trying to lock the screen orientation to 'portrait' on a script. If I load a ui using ui.load_view('pyui_file_name'), and then present it with present(style = 'full_screen', orientations = ['portrait']), the orientation stays locked in portrait mode. If I create a ui.view class in code and then create and load subviews of that class, and then present() it in the same way, the screen does not stay locked in portrait. This script is running on an iPhone 6+. What am I missing here?
-
@Webmaster4o when you rotate the screen, what happens to the clock and battery indicator at the top of your screen?
-
@ccc They stay in place. Just tested.
-
For me the Pythonista UI orientation remains locked but the clock and battery rotate. Pythonista version 2.0.1 (201005) on iOS 9.2.1 on an iPad3,4.
-
The last 2 lines were a copy paste error. I copied the exact code to a blank script and ran it. The orientation is still not locked. I am using an iPhone 6+. I tried hard coding the frame size ...self.frame = (0, 0, 414, 736), but that didn't work either. My next thought would be to create a pyui file and load it with ui.load_view(). I read your comment about not needing a class for this. Maybe that would make a difference. Obviously I've got some things to learn. Thanks for all your input...much appreciated.
-
@coomlata1 yeah, but a class does work just fine, you just don't need it. Your code works for me with a class
@ccc I'm on a newer iOS version than you, the iOS 9.3 beta.
So, it could be an iPhone vs iPad issue, or an iOS version issue.
What do you think, @omz?
-
The first line in my imports was:
'from future import(absolute_import, division, print_function, unicode_literals)'
After removing that line, the orientation worked as expected and stayed locked in portrait mode. That line was put in early last year to aid in being forward compatible with Python 3 changes. The script was console based at that time with no ui.
Thanks again for your comments...great forum.
-
Hmm, not sure what's up with this. I'm seeing some weird issues with status bar rotation now (view doesn't rotate, but status bar does), not sure if that's related to changes I made in the beta, but I guess I have to look into the whole auto-rotation thing again... :/
It could be that the issue in this thread was about unicode literals, I'm not sure right now if
ui.View.present()
handles unicode correctly.
-
On my iPhone 6+ the status bar and view both stay locked.
-
Turns out the bug I was seeing is totally unrelated to this. It had to do with showing a
console.hud_alert
before presenting the view, which apparently screws up the auto-rotation system. I'll have to look into that.