0

For various optimization purposes, I want to get the device's max display size without the safe areas for both portrait and lanscape.

I can use the UIWindow's safeAreaInsets, but that only gives me the current safe areas, not the one for opposite layout (assuming there is only portrait and landscape).

I had a look at UITraitCollections (I really thought I could achieve it with it), but it seems like a dead end.

Anyone can help me with that ?

Thanks!

Khal
  • 790
  • 5
  • 23
  • What if the app is running on an iPad in Split-View or Slide-Over multitasking? Maybe if you describe what you are doing for "optimization"? – DonMag Oct 13 '22 at 14:20
  • Thx DonMag, but even in this case, there will be a dedicated scene for every display, so the question remains the same. The optimisation part is to load on the server side an HTML with assets that is exactly the size of the display area, but I'm not sure that will help my question in any case ;-) – Khal Oct 14 '22 at 05:44
  • FYI, I tried with appearance, but safeAreaInsets are .zero and safeAreaLayoutGuide is still nil, that's a shame :-/ let appearance = UICollectionView.appearance(for: self.traitCollection, whenContainedInInstancesOf: [UIViewController.self, UINavigationController.self]) print(" \(appearance.safeAreaInsets) - \(appearance.safeAreaLayoutGuide)") – Khal Oct 14 '22 at 07:33
  • So... I assume you're disabling multitasking? You question, though, is a little ambiguous -- *"get the device's max display size without the safe areas"* ... do you mean you want the **safe area size**? Or, do you mean the **full screen size**? – DonMag Oct 14 '22 at 13:18
  • If I know the safeArea insets in both mode, I can compute everything I need. And yes, let's say multitasking is off ;-) – Khal Oct 17 '22 at 05:41

0 Answers0