Home > Mobile >  Device orientation : 'windows' was deprecated in iOS 15.0
Device orientation : 'windows' was deprecated in iOS 15.0

Time:09-26

I have been getting the interface orientation using the following line of code.

let orientation = UIApplication.shared.windows.first?.windowScene?.interfaceOrientation

However, my new app is targeting iOS 15 and above and I now receive a warning 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

CodePudding user response:

I discovered in another question, that a way around this warning is to instead use the views window and window scene to get the interface orientation like so

let orientation = self.view.window?.windowScene?.interfaceOrientation

The warning goes away now. Thank you to @Marian König's answer

CodePudding user response:

You should start with UIApplication.shared.connectedScenes. You probably only have one.

  • Related