Position Relative to screen center
How would I position a UI view relative to the center of the screen, no matter the orientation?
Do I use the size_to_fit() function?
Do I have to make the ui view a sub view of a larger view? If so, how will that view be oriented when the iPad is rotated (sounds too complex to be the solution).
I am trying to make the view show up in the center of the screen, and scale to fit horizontally.
Okay, it is flexing when I rotate the ipad, but what do I set the popover_location parameter of the UI.present() function to, to center the UI in the center if the screen when I run the workflow.
It would seem that there is a constant for the screen's center, without having to use another UI element as the parent. This way, if someone is using a different screen size, it will take the dimensions of the screen and divide both the height and width by two, and then center at those coordinates.
To center my button in a parent view I had to do:
button.center = (window.width/2,window.height/2)
But the window itself, I want to center in the screen, No matter what screen size or orientation.
I found ui.get_screen_size(). How do I get the length component separate from the height component?
You can't really do that with a popover because it's currently not possible to get the current orientation. You might want to consider using a sheet instead...
Could I resize the dimensions of a sheet?
Also, I tried this:
And it almost works. I used it along with flex too.
The portrait orientation is off, but, well take a look
Hmmm! I just saw that the screen size function would locate the arrow of the popover at the center! not the center of the popover. That is why it is off.
While there is nit an easy way to get orientation, if the keyboard frame is displayed, you can use
ui.get_keyboard_frameto determine the current orientations width.
Take that back...
Does give you orientation.
Okay. Thanks. I put this one on hold. I may pick it up later. Thanks!
I have picked this back up:
screen_size = ui.get_screen_size()
screenX = screen_size
screenY = screen_size
window = ui.load_view()
window.flex = "WL"
window.height = 200
window.width = screenX
view = window['view2']
view.text = workflow.get_input()
Now I have to add the orientation
This includes a 1 pixel webview, which is used to get orientation, see e.g. line 61 and following for the possible values