September 26, 2010 0

Post-A-Day #6 – UIViewController subview is 20 pixels too high!!!

By admin in Uncategorized

This is a small tip which I’ve encountered twice so far on my current project, and a few times before. The times were far apart enough, that by the time I encountered it again I forgot what the solution was. Just that it was fixible….er somehow.

Problem:

-You created a new class of UIViewController type, with an attached XIB.
We will call it “RootViewController”
-You created a new class, also of UIViewController type, with attached XIB. Which gets added to RootViewControllers, .view property.
We will call it “SecondViewController”
-When you fire up in the simulator, it appears that “SecondViewController” does not fill to the bottom of the screen for some reason! It’s just shy of hitting the bottom, 20 pixels off to be exact.

Reason:

When you created your RootViewController, and opened the corresponding XIB file in InterfaceBuilder, you removed the status bar from the “Simulated User Interace Elements”. However InterfaceBuilder failed you, and did not fix your Views frame to “unsimulate” the StatusBar.

Solution:

Open RootViewController.xib
Select your view
Press Option+3.
Notice your view’s frame property, it is 460.
Make it 480 pixels high.

Ugh the first time that happened to me i can’t tell you how much i surfed thru stack overflow, turns out the failure is on interface builder not anything in code.

Tags:

Leave a Reply

Powered by WP Hashcash

Spam protection by WP Captcha-Free