Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
UI Orientation Issues...Staying locked
-
@coomlata1 Well this is not at all how you're supposed to use custom view classes. You don't need a custom view class at all in this case.
In your code, do you have the code that says
v = MyView() v.present(style = 'full_screen', orientations = ['portrait'])
actually inside the custom view code, or was that a copy/paste error? If it wasn't, I suggest you move it out.
-
For me, simply modifying the end of the code to read
# The beginning of your code self.add_subview(self.tf1) self.add_subview(self.tf2) self.add_subview(self.lb1) self.add_subview(self.lb2) self.add_subview(self.iv) self.flex = 'WHLRTB' #self.tf1.begin_editing() # <<<< Dedent below <<<< v = MyView() v.present(style = 'full_screen', orientations = ['portrait'])
works flawlessly. After dedenting the last two lines, do you still have the issue?
-
@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.