I have been using the attemptRotationToDeviceOrientation
function to change the orientation of some ViewController when the user presses a button. However, as of iOS 16, this function has been officially deprecated.
What can I use as the replacement?
2
Answers
According to release note: https://developer.apple.com/documentation/ios-ipados-release-notes/ios-16-release-notes?changes=lat__8_1
I think you may have to use setNeedsUpdateOfSupportedInterface.
I think you may have to use setNeedsUpdateOfSupportedInterface.
this can be done in two ways.
personally I prefer this way
1.keep this function in AppDelegate to handle the orientation(this is must)
2. in which ViewController you want the force orientation, go to that view controller and add these lines in the variable declaring section
we will be updating the forceLandscape so it will get updated, then the supportedInterfaceOrientations also will get updated
3. Here we are setting the trigger for updating the forceLandscape (we can add these lines of code inside button action for handling IOS 16 force roatation)
this will update the forceLandscape, so it will check the orientation and update according to it