2
votes

I am developing iPad landscape app using storyboard. I have done below steps for same. My app is screen is opening in Landscape on simulator.. But getting wrong frame.

  1. Sample app template from xcode for storyboard.
  2. Allow only landscape orientation from info-plist file
  3. Storyboard -> UIViewController -> Simulated matrices -> Changed orientation to Landscape
  4. Implemented below method in view controller.m

           - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
        {
         // Return YES for supported orientations
       return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)); 
            } 
    

Now when I take NSLog of frame and bounds it show me portrait frame.

   - (void)viewDidLoad
  {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"bounds ::%@",NSStringFromCGRect(self.view.bounds));
    NSLog(@"frame ::%@",NSStringFromCGRect(self.view.frame));
   }

Result Log :

   bounds ::{{0, 0}, {748, 1024}}

   frame ::{{20, 0}, {748, 1024}}

Am I missing anything ?

2

2 Answers

5
votes

In viewDidLoad method you dont get correct bounds. You do it in viewDidAppear method. viewDidAppear method is called when view is loaded fully and has correct bounds.

0
votes

Try setting this and see the output.

bounds ::{{0, 0}, {1024, 748}}

frame ::{{20, 0}, {1024, 748}}