Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/Essentials/src/DeviceDisplay/DeviceDisplay.ios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ protected override void StartScreenMetricsListeners()
// NSApplicationDidChangeScreenParametersNotification - for resolution/refresh rate changes
observer = notificationCenter.AddObserver(ScreenParametersChangedNotification, OnMainDisplayInfoChanged);
#else
// On iOS, use status bar orientation changes (deprecated but still works)
var notification = UIApplication.DidChangeStatusBarOrientationNotification;
// On iOS, stop using deprecated status bar orientation changes as they noi longer work and switch to UIDevice.OrientationDidChangeNotification)
var notification = UIDevice.OrientationDidChangeNotification;
Comment thread
jgold6 marked this conversation as resolved.
Resolved
observer = notificationCenter.AddObserver(notification, OnMainDisplayInfoChanged);
#endif
}
Expand All @@ -181,17 +181,17 @@ void OnMainDisplayInfoChanged(NSNotification obj) =>
#pragma warning disable CA1416 // UIApplication.StatusBarOrientation has [UnsupportedOSPlatform("ios9.0")]. (Deprecated but still works)
#pragma warning disable CA1422 // Validate platform compatibility
static DisplayOrientation CalculateOrientation() =>
UIApplication.SharedApplication.StatusBarOrientation.IsLandscape()
UIDevice.CurrentDevice.Orientation.IsLandscape()
Comment thread
jgold6 marked this conversation as resolved.
Resolved
Comment thread
jgold6 marked this conversation as resolved.
Resolved
? DisplayOrientation.Landscape
: DisplayOrientation.Portrait;
: UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.PortraitUpsideDown || UIDevice.CurrentDevice.Orientation == UIDeviceOrientation.Portrait ? DisplayOrientation.Portrait : DisplayOrientation.Unknown;

static DisplayRotation CalculateRotation() =>
UIApplication.SharedApplication.StatusBarOrientation switch
UIDevice.CurrentDevice.Orientation switch
{
UIInterfaceOrientation.Portrait => DisplayRotation.Rotation0,
UIInterfaceOrientation.PortraitUpsideDown => DisplayRotation.Rotation180,
UIInterfaceOrientation.LandscapeLeft => DisplayRotation.Rotation270,
UIInterfaceOrientation.LandscapeRight => DisplayRotation.Rotation90,
UIDeviceOrientation.Portrait => DisplayRotation.Rotation0,
UIDeviceOrientation.PortraitUpsideDown => DisplayRotation.Rotation180,
UIDeviceOrientation.LandscapeRight => DisplayRotation.Rotation270,
UIDeviceOrientation.LandscapeLeft => DisplayRotation.Rotation90,
_ => DisplayRotation.Unknown,
};

Expand Down
Loading