Skip to content

Commit 4ee8087

Browse files
committed
Device orientation for iOS 16 compatibility
1 parent ef19a48 commit 4ee8087

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Source/Fuse.Platform/iOS/SystemUI.uno

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,33 @@ namespace Fuse.Platform
506506
}
507507
}
508508
}
509+
#if defined(__IPHONE_16_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0
510+
if (@available(iOS 16.0, *)) {
511+
for (UIScene* scene in UIApplication.sharedApplication.connectedScenes) {
512+
if (![scene isKindOfClass:[UIWindowScene class]]) {
513+
continue;
514+
}
515+
UIWindowScene* windowScene = (UIWindowScene*)scene;
516+
UIInterfaceOrientationMask currentInterfaceOrientation = 1 << windowScene.interfaceOrientation;
517+
if (!(@{supportedOrientation:Get()} & currentInterfaceOrientation)) {
518+
[[[windowScene keyWindow] rootViewController] setNeedsUpdateOfSupportedInterfaceOrientations];
519+
UIWindowSceneGeometryPreferencesIOS* preference =
520+
[[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:@{supportedOrientation:Get()}];
521+
[windowScene requestGeometryUpdateWithPreferences:preference
522+
errorHandler:^(NSError* error) {
523+
NSLog(@"Failed to change device orientation: %@",error);
524+
}];
525+
}
526+
}
527+
}
528+
else
529+
{
530+
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
531+
}
532+
#else
509533
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
534+
#endif
535+
510536
@}
511537
}
512538
}

0 commit comments

Comments
 (0)