InterfaceOrientation deprecated in iOS 8

Deepak Sharma picture Deepak Sharma · Apr 18, 2015 · Viewed 8.8k times · Source

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 ?

Answer

Tharoth picture Tharoth · Oct 22, 2015

Should change

if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
  ...
}

to

if (UIInterfaceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation])) {
  ...
}