I’m developing a mobile app where the default orientation is portrait. I want to trigger landscape orientation on a specific screen and return to portrait when exiting that screen. On Android, I can use SetAllowedDeviceOrientation
to dynamically switch the screen orientation. However, it doesn’t seem to work on iOS. I tried enabling SupportsLandscapeLeftOrientation
, but the screen rotates automatically following the device orientation, which is undesirable. Is this a bug in UE5.1? I haven’t tried other versions, and this has left me feeling confused.
2 Likes
Hi! Did you find solution?
Sorry, I have already resolved this issue. You might need to add some Objective-C code yourself. After calling SetAllowedDeviceOrientation
, call ForceRefreshIOSOrientation
. For example:
void UCustomizeIOSFunctionLibrary::ForceRefreshIOSOrientation()
{
#if PLATFORM_IOS
dispatch_async(dispatch_get_main_queue(), ^{
if (@available(iOS 16.0, *)) {
[[IOSAppDelegate GetDelegate].IOSController setNeedsUpdateOfSupportedInterfaceOrientations];
} else {
[UIViewController attemptRotationToDeviceOrientation];
}
});
#endif
}
This might not be the best method, but it works for me.
2 Likes
Oh, nice, thank you. I will try
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.