I'm working on a project in which when the user press a button a video will be played, I have to program this app for all orientations. I have added images as background for buttons given those buttons position based on the size of the superview like this:
button1.frame = CGRectMake(0.15 * (self.view.frame.size.width),0.15 * (self.view.frame.size.height), 0.2 * (self.view.frame.size.width), 0.2 * (self.view.frame.size.height)); When I start the app in portrait it's view is fine and also when I rotate it works fine :

But if I start my app in landscape it shows a view like this:

I'v used a lot of code to resize views and subviews:
-(void) viewDidLoad { ... self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [self.view setAutoresizesSubviews:YES]; button1.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; ... } and in didRotateFromInterfaceOrientation() and willRotateToInterfaceOrientation():
... self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; [self.view setAutoresizesSubviews:YES]; button1.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; ... I'v also specified YES for return in shouldAutoRotate(). What am I lacking here? Any help will be appreciated.