How to lock the orientation in `ui.View.present()`
-
I tried two different ways to lock the orientation of my app: provide an empty list as parameter to the
orientations
parameter of methodui.View.present()
or provide the list('landscape')
. Neither approaches worked for me. The app was still allowed to change orientation into portrait mode. What am I doing wrong? Thanks a lot!
-
Does this work for you?
view.present(orientations=['landscape'])
view is the view you want to present
-
@shaun-h , lol I made the same mistake. Didn't pass a list.
Great catch
-
I am glad that worked
-
If you want to make a one-element tuple, you need to write
("landscape",)
with the extra comma. Otherwise the parentheses are interpreted as a normal operator grouping thing, not a tuple.
-
@dgelessus This works. This is too embarrassing. I'm inclined to delete this thread... :-)