Search code examples
iphoneiosipadios6

Device orientation handling in iOS 6 during view load?


I have a Tab bar application. I was using XCode 4.3.3. I have upgraded to 4.5.2 with iOS6 stuffs.

My code in the shouldAutorotateToInterfaceOrientation for each view will check the current device orientation and place all the UI components properly.

But after upgrading to iOS 6, this code is not executing. I have tried for almost one day to fix this, but had no luck.

I have also tried

UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation]; 

in viewLoad, viewDidLoad, viewWillAppear

What should I do if I want to check the orientation during the view load and place the UI components to appropriate places during view load. Kindly give your suggestion.

Thanks


Solution

  • if you want to check which is current orientation, then you just write in prifix.pch below line

     #define isPortrait [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortraitUpsideDown
    

    then where you want to check orientation ,write condition like below

        if(isPortrait)
        {
           //portrait mode....
        }
        else
        {
           //landscape mode....
        }
    

    let me know it is working or not...

    Happy coding!