How can I write my code which supports both landscape and portrait? I tried this one –
(void)setupForOrientation:(UIInterfaceOrientation)orientation {
if (UIInterfaceOrientationIsPortrait(orientation)) {
CGRect bounds = CGRectMake(0, 0, 768, 1004);
scrollView.frame = bounds;
// Other view positioning for portrait.
} else {
CGRect bounds = CGRectMake(0, 0, 1024, 748);
scrollView.frame = bounds;
// Other view positioning for landscape.
}
[self drawBackgroundForOrientation:orientation];
}
But its not working. Please help me.
Use this code:
You’ll always have to return yes for this function whenever you require orientation support.
Edit 1: P.S. I’ve taken portraitView & landscapeView as two separate UIViews.