iOS Question landscape 100%x returns the width of portrait

sorex

Expert
Licensed User
Longtime User
Hello,

It's the first time I try to do something in forced landscape mode.

All seemed fine when I ran my app on the 4S at work (ios 9 I think).

When I run it here on my own 4S (ios 7) it seems to position everything as if it was in portrait mode.
Including an empty gap on the right.

When I do a log(100%x & " " & 100%y) it returns 320 480 which proves the detection of portrait mode.

The black screen from the debugger when the app starts is in landscape tho so I guess the app is aswell.

Did anyone notice this before and how can it be fixed or bypassed?
 
Last edited:

sorex

Expert
Licensed User
Longtime User
page1.rootpanel.width & .height return the correct landscape dimensions tho.

does that mean that 100%x & 100%y are giving the dimension of the panel or something else where this page1 is located in and when created at run time this container was sized to portrait mode?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
This event is never called in this case. (because it's already resized by the bridge?)
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, I seem to have found the culprit.

in application start I initialize my game class which creates a bunch of panels, images ...

this kind of holds the resize process so it still works with the portrait dimensions.

moving the init to the resize sub doesn't solve it either. it doesn't seem to work there at all and I don't see anything being added to the screen.

when I use a timer and let the init execute after a second then it shows up like on the other device.

I just have one more question...

What triggers the resize sub? if I dissable that timer the resize sub doesn't execute at all. Does it happen from the moment you add a view to it?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
here's an example file where the resize is not triggered at all and the only way to get it working right is with that timer.

change the if 0=0 to 0=1 to test the other mode.

it also happends in release mode so it's not caused by delays of the debugger.

the resize doen't hit on the other phone either but there the dimensions are right at app start.
 

Attachments

  • 100x.zip
    87.8 KB · Views: 263
Upvote 0

sorex

Expert
Licensed User
Longtime User
Thanks for checking this out and the hint of the missing init parameter!

Now it works as expected when I place the game init inside the resize event.
Strange that this didn't pop up earlier in my other games.

I never use the designer as I use code sharing over multiple OS's it's easier to do it with code.
I know about the bal2bil tool but I had to manually fix or create too many things due to changes between B4A & B4i that it takes more time using that then to code it.
Games need to be quite flexible sometimes so it's hard to stick to the designer only.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I never use the designer as I use code sharing over multiple OS's it's easier to do it with code.
I actually think that it is easier to create cross platform solutions if you do use the designer. The designer itself is identical and it takes care of dealing with the different ways that orientation (and other resizing cases) is handled in each of the platforms.
 
Upvote 0
Top