I have code with several instances of:
if (!UIInterfaceOrientationIsPortrait([UIApplication sharedApplication].statusBarOrientation))
{
backgroundImage = [UIImage imageNamed:@"Background-Default-Portrait.png"];
}
else
{
backgroundImage = [UIImage imageNamed:@"Background-Default-Landscape.png"];
}
Note the ! in front of UIInterfaceOrientationIsPortrait(). I find that when the app is first initializing, it works correctly with the NOT and pulls the correct background whether the app is first initializing, but then either rotating from there to landscape and portrait with the wrong app.
I've circumvented the problem for the moment, at the expense of DRY and good engineering, by having two copies of the code, one appropriate for an app just loading, and one at the expense of a view refresh. But I'd like to know what a better way is of doing it. I could make the conditionals more baroque, but what I've found is that UIInterfaceOrientationIsPortrait() returns one style of values when I call it from initializing code, and another when called when the device is rotated between landscape and portrait.