I am have trouble trying to update our app from relying on "shouldAutorotate". We are using Objective C.
Currently, in iOS15, the "shouldAutorotate" updates the location and size of some items in the current view depending on the orientation of the device.
However, in iOS16, shouldAutorotate is deprecated. I have reviewed the docs, but I am soooo confused, can anyone help? Any examples on how to implement this???
I will first answer to the title question, since that's how I came across this post. So, I have an app where only some of the ViewControllers need to stick to the orientation you launch them in while they are displayed. This used to work simply by having:
So, for iOS 16 I had to first get the launch orientation on loadView:
Then allow only that specific orientation:
Now, moving on to the OP's detailed question, I am pretty sure
shouldAutorotatewas never the place to make layout and it would have always been bad practice to put such code in there. I mean, system code is doing expecting it to be a fast function returning a BOOL value and using it as such. Instead, you can trigger orientation layout changes from:Or use
layoutSubview/viewWillLayoutSubviews/viewDidLayoutSubviews.