I'm adding a subview to a view controller, whose dimensions are 1024(W) x 768(H). My app is set to support only landscape in the plist, and yet my subview will always display in portrait orientation, its bottom disappearing off the screen.
My superview:
#import "TSTViewController.h"
#import "TSTContentViewController.h"
@interface TSTViewController ()
@property (nonatomic, strong) TSTContentViewController *tcvc;
@end
@implementation TSTViewController
- (void)loadView
{
UIView *rootView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 1024.0f, 768.0f)];
[rootView setBackgroundColor:[UIColor yellowColor]];
self.view = rootView;
_tcvc = [[TSTContentViewController alloc] initWithNibName:@"TSTContentViewController" bundle:nil];
[rootView addSubview:_tcvc.view];
}
- (void)viewDidAppear:(BOOL)animated
{
NSLog(@"H:%f W:%f; H:%f W:%f", self.view.frame.size.height, self.view.frame.size.width, _tcvc.view.frame.size.height, _tcvc.view.frame.size.width);
}
@end
My app delegate:
#import "TSTAppDelegate.h"
#import "TSTViewController.h"
@implementation TSTAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[TSTViewController alloc] init];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
My subview (TSTContentViewController) has no custom code, and a nib with dimensions (1024W X 768H), with a gray background.
Seemingly unconditionally, the result looks like:
(yellow superview, gray subview)
The NSLog in viewDidAppear prints that both views have portrait orientation dimensions, even the yellow one, that actually looks like it is in landscape orientation.
Any ideas?
Edit for additional detail:
If the width of the subview is just one pixel smaller, the view goes landscape like it should (see thin yellow strip below).
According to my observations, only exactly fullscreen causes this subview rotation. Smaller and larger frames preserve the dimensions defined in the nib.