Reputation: 1878
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.
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 ?
Upvotes: 2
Views: 1515
Reputation: 1951
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.
Upvotes: 5
Reputation: 924
Try setting this and see the output.
bounds ::{{0, 0}, {1024, 748}}
frame ::{{20, 0}, {1024, 748}}
Upvotes: 0