Home > Blockchain >  How to resolve : 'windows' was deprecated in iOS 15.0
How to resolve : 'windows' was deprecated in iOS 15.0

Time:09-27

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

How do I get rid of this warning and what is the best way to retrieve the device orientation in iOS 15?

CodePudding user response:

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

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

  • Related