I am not using Size classes in my project and continue to use old methods for view controller orientation. I am getting deprecation warnings, such as when I use code below :
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
I have searched a lot but could not find the right way to fix it. Any suggestions ?
Should change
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
...
}
to
if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
...
}
Since iOS8, Apple recommends to use TraitCollections (Size Classes) instead of interfaceOrientation.
Moreover, since iOS 9 and the new iPad feature "Multitasking", there are some cases where the device orientation doesn't fit with the window proportions ! (This leads to brake your application UI)
However, sometimes TraitCollections doesn't fill all your design needs. For those cases, Apple recommends to compare view's bounds :
if view.bounds.size.width > view.bounds.size.height {
// ...
}
I was quite surprised, but you can check on the WWDC 2015 video Getting Started with Multitasking on iPad in iOS 9 at 21'15.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With