"Should've known better...."

"...but I got what I deserved"

So today I got bitten by a small behaviour change between iOS versions. I'm glad actually as it exposed an issue that I should have seen but missed.

Here's the scenario...
I'm in the viewWillAppear: method of my UIViewController subclass. It's backed by a .xib.
It'll present as a modal so fullscreen on the phone and a 620x540 window on iPad. 
I need to do the following here for reasons to arcane to go into now. I'm creating and adding subviews to the view at this point, each one has it's origin y value set as the max y of the previous one, by calling CGRectGetMaxY() on the previous view. With one exception: the final view is a set of buttons positioned flush to the bottom of the view.
So to place it correctly I'm getting the height of the view with CGRectGetHeight() and subtracting the known height of the button elements.

See the problem?

At this point, in viewWillAppear: the view controller technically doesn't know it's height so calculating from it can result in odd things.
I didn't see it in the Simulator or my principal test device (iPhone 4 running 7.0.3). The return from CGRectGetHeight in viewWillAppear returns the correct value.
But I DO see it on any device running 7.0.4. where the function call returns the height of the underlying xib file, which happens to be sized for iPhone 5. On the 3.5" phone screen the buttons are positioned out of the views bounds.

I'll need to make some test cases with and without xibs etc... but for now it looks to me like 7.0.3 and 7.0.4 report the main views height differently at that point in the views lifecycle.

Lesson learned!

To fix it, conditionally for the iPhone, I used the keyWindow property of UIApplication to determine the window frame size and used that as the guide to the height. If you can think of a better way do it, shout.
Just remember I have to make the call in viewWillAppear, so shifting it all to viewDidAppear isn't an option.

Letraset for action!...

Whither now, Automator?...