0

I used below code, it works fine ios 6 but when in Xcode 5(ios7), it has error so I can not build project. Is there another way to set to Portrait view when viewcontroller appear? Please help me. Thanks

CGFloat ios = [[[UIDevice currentDevice] systemVersion] floatValue];
CGFloat min = 5.0;
if (ios >= min)
{
    if (self.interfaceOrientation != UIInterfaceOrientationPortrait)
    {
        if([self shouldAutorotateToInterfaceOrientation:UIInterfaceOrientationPortrait])
        {
            [[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
            [self willRotateToInterfaceOrientation:self.interfaceOrientation duration:0];
            [UIViewController attemptRotationToDeviceOrientation];
        }
    }
}
Shaik Riyaz
  • 11,204
  • 7
  • 53
  • 70
user3125692
  • 85
  • 3
  • 11

1 Answers1

0

Use have set the this on info plist.

from plist choose

Supported interface orientations (iPad)-->add item as Portrait (bottom home button)

and add this code

     -(BOOL)shouldAutorotate
      {

           return NO;
      }

         -(NSUInteger)supportedInterfaceOrientations
        {
          return UIInterfaceOrientationMaskPortrait;;
         }
praveen
  • 1
  • 2