I tried two different ways to lock the orientation of my app: provide an empty list as parameter to the orientations parameter of method ui.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!
Forum Archive
How to lock the orientation in `ui.View.present()`
marcus67
Jan 31, 2016 - 11:36
shaun-h
Jan 31, 2016 - 12:14
Does this work for you?
view.present(orientations=['landscape'])
view is the view you want to present
Phuket2
Jan 31, 2016 - 12:22
@shaun-h , lol I made the same mistake. Didn't pass a list.
Great catch
shaun-h
Jan 31, 2016 - 12:41
I am glad that worked
dgelessus
Jan 31, 2016 - 13:37
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.
marcus67
Jan 31, 2016 - 15:19
@dgelessus This works. This is too embarrassing. I'm inclined to delete this thread... :-)