Skip to content

Commit

Permalink
Merge pull request #1454 from ichan-mb/fix_orientation
Browse files Browse the repository at this point in the history
Device orientation for iOS 16 compatibility
  • Loading branch information
mortend authored Nov 13, 2022
2 parents ef19a48 + 4ee8087 commit a41a69a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Source/Fuse.Platform/iOS/SystemUI.uno
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,33 @@ namespace Fuse.Platform
}
}
}
#if defined(__IPHONE_16_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_16_0
if (@available(iOS 16.0, *)) {
for (UIScene* scene in UIApplication.sharedApplication.connectedScenes) {
if (![scene isKindOfClass:[UIWindowScene class]]) {
continue;
}
UIWindowScene* windowScene = (UIWindowScene*)scene;
UIInterfaceOrientationMask currentInterfaceOrientation = 1 << windowScene.interfaceOrientation;
if (!(@{supportedOrientation:Get()} & currentInterfaceOrientation)) {
[[[windowScene keyWindow] rootViewController] setNeedsUpdateOfSupportedInterfaceOrientations];
UIWindowSceneGeometryPreferencesIOS* preference =
[[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:@{supportedOrientation:Get()}];
[windowScene requestGeometryUpdateWithPreferences:preference
errorHandler:^(NSError* error) {
NSLog(@"Failed to change device orientation: %@",error);
}];
}
}
}
else
{
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
#else
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
#endif

@}
}
}

0 comments on commit a41a69a

Please sign in to comment.