I have the answer! One of my friends helped me out with this one.
Views are not oriented until they appear, so, if you are going to add any components to the view and expect them to adhere to an orientation other than the default, which I suspect is portrait, you must add those components in the -(void)viewDidAppear:(BOOL)animated
. I was calling methods that added several components to the view from within the viewDidLoad
method, however, the view has not appeared, and the orientation not set, when that method is called. Moving my initialization code into the viewDidAppear
method fixes my problem.
Here is an example:
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidLoad];
//Probably dont want to draw stuff in here, but if you did, it would adhere to the
//correct orientation!
CAShapeLayer *layer = [CAShapeLayer layer];
layer.backgroundColor = [UIColor blueColor].CGColor;
layer.anchorPoint = CGPointMake(0, 0);
layer.bounds = CGRectMake(0, 0, self.view.bounds.size.width, 300);
[self.view.layer addSublayer:layer];
//Call methods from here
[self initializeScrollView];
[self addItemToScrollView];
[self addGraphToView];
}