Screen Orientation iOS

I am facing two issues with Screen Orientation with iOS.
I want to lock orientation in Portrait mode, so in Designer, ScreenOrientation is set to "Portrait" and this works fine for Android devices as well as iPhone. But on iPad, auto orientation based on sensor is used (automatic switch between Portrait and Landscape according to iPad orientation.
In order to lock in Portrait Mode, I tried to program the orientation in blocks:
image
But when I use these buttons, I get the message:
image
for both iPhone and iPad
Is it as for the permission where we need to replace Permission.FineLocation with "ACCESS_FINE_LOCATION" for iOS? ? What should be the text to set the orientation?
Looks like iPad and iPhone do not behave the same? Is App Inventor supporting both?
Thanks for your help and support

From another topic:

To get the screen orientation we usually use

If screen width > height
Then landscape
Else portrait

Taifun

Screen orientation blocks are still a bit of a mystery...

I agree with your feedback. However this does not explain / solve the issue I am facing with iPad and iOS: How can we set landscape or portrat with iOS?

Did you try the above ?

When I set to User, my device display a little button to press to rotate the screen. This is on Android.

If this also happens on ios, it may be of use ?

I tried to setup orientation to User in Designer:

image

Then I have two button to switch to Portrait or Landscape:
image
It works fine with Android, but with iOS I get (randomly) an irritant message:


and it does not work (iPhone and iPad)
Here is my small test app: Test_Orientation.aia (9.7 KB)

Try "portrait" and "landscape" as strings (from the "Text" block section). Some Helper blocks might still not work on iOS.

Thanks for the idea (Actually that was what I mentioned in my initial post: Is it as for the permission where we need to replace Permission.FineLocation with "ACCESS_FINE_LOCATION" for iOS? ? What should be the text to set the orientation?)

I tried with portrait & landscape strings (Lowercase and UpperCase), but it does not work with iOS (OK with Android), even if I do not have anymore the irritant pb, but it does not work.

If I set it to landscape, I get this message (iPad Pro, 12,9):

"Screen Orientation
This app works best in landscape
mode. Please rotate your device."

regardless of the current orientation.

This doesn't work on iPads because Apple does not provide an API for enforcing it (at least without also forcing the companion app to be a full screen only app, which we don't want to do), hence the message about the orientation. It should work on an iPhone.

There is the separate issue of the ScreenOrientation helper blocks, which we still need to port to iOS. You have to use the strings for now.

1 Like

Does it mean the API is different for iOS and iPadOS, and forcing orientation exists with iPhone and not with iPad. That what I see, when testing with this App: Test_Orientation.aia (9.7 KB)

image
Works fine on iPhone, not on iPad.

Is there a web site describing difference between iOS & iPadOS? (and potential compatibility pb between these devices when building App with App Inventor?

Thanks a lot

That's correct, and it's been this way for quite a while for better or for worse. I think it has to do with the fact that on most iPads now a days apps can exist in multiple windows so the idea of landscape and portrait vis a vis the device orientation doesn't make sense. I don't know why if the app is full screen we couldn't just keep the iPhone behavior but that is Apple's decision.

I guess one potential workaround is that for compiled apps we could set the flag in the Info.plist file to make the apps be forced full screen, in which case it might work. I don't have an iPad with me today to test but I can see if that would help at all.

Thanks for these clarifications
I tried to modify the .ipa of my App, editing the info.plist and adding the key: UIRequiresFullScreen and set it to true:
Capture d’écran 2024-12-20 115621
But when I try to install it on my iPad after this modification, it cannot be installed due to integrity problem.
I suppose there is a signature, and as I modified a file, signature is wrong......
Anyway, the status is clear and I set Solution to OPK :slight_smile:

Correct, either you would need to resign the app on your end, or we can try to figure out a way to support it in App Inventor. One logical solution would be to add a project level property that you can check to enable full screen mode.

1 Like

A post was merged into an existing topic: Help test nb200

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.