First of all, you don't want to look at the UIDevice orientation (see this post).
I think you're getting a spurious result before the UI is done configuring itself. In other words, it reports Portrait because it's just not ready at that point in the startup process. Why is it sending notifications at all? Not sure; but, you definitely don't want to use them for your task.
I don't quite understand what you're using the initial orientation for, but I have an alternate way to solve your problem: you can keep a view static by counter-rotating it. When your view controller receives a rotation message (I.e. viewDidRotate, pre-iOS 8), you change the transform on your static view to rotate in the direction opposite that rotation.
There are probably some clever ways to do it with autolayout as well, but I haven't figured them out yet... :-p
EDIT:
Some code...
YMMV -- this works, but I haven't touched it in a while! You might have to play with it a little... and contrary to what I said in the comments, it looks like I am animating the rotation. But, it really doesn't move! I think the counter-rotation animation gets cancelled out by the system's rotation of the whole display... or something.
simViewControllerContainer is the view I'm preventing from rotating.
- (void)viewDidLoad
{
[super viewDidLoad];
// Set simView container's orientation if the device started in landscape
if ( self.interfaceOrientation == UIInterfaceOrientationLandscapeRight ) {
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
simViewControllerContainer.transform = CGAffineTransformMakeRotation(-M_PI/2);
}
else if ( self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
simViewControllerContainer.transform = CGAffineTransformMakeRotation(M_PI/2);
}
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
BOOL doubleRotation =
(UIInterfaceOrientationIsPortrait(self.interfaceOrientation) && UIInterfaceOrientationIsPortrait(toInterfaceOrientation)) ||
(UIInterfaceOrientationIsLandscape(self.interfaceOrientation) && UIInterfaceOrientationIsLandscape(toInterfaceOrientation));
if ( toInterfaceOrientation == UIInterfaceOrientationLandscapeRight ) {
[UIView animateWithDuration:duration animations:^{
if ( !doubleRotation ) {
// For a double-rotation, we don't want to change the center -- it's the same:
// a double-rotation is landscape to landscape or portrait to portrait -- same center.
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
}
simViewControllerContainer.transform = CGAffineTransformMakeRotation(-M_PI/2);
}];
}
else if ( toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ) {
[UIView animateWithDuration:duration animations:^{
if ( !doubleRotation ) {
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
}
simViewControllerContainer.transform = CGAffineTransformMakeRotation(M_PI/2);
}];
}
else if ( toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ) {
[UIView animateWithDuration:duration animations:^{
if ( !doubleRotation ) {
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
}
simViewControllerContainer.transform = CGAffineTransformIdentity;
}];
}
else if ( [UIDevice currentDevice].orientation == UIDeviceOrientationPortrait ) {
[UIView animateWithDuration:duration animations:^{
if ( !doubleRotation ) {
simViewControllerContainer.center = (CGPoint) {self.view.bounds.size.height/2, self.view.bounds.size.width/2};
}
simViewControllerContainer.transform = CGAffineTransformIdentity;
}];
}
}