Suggestion: Simulated Metrics to help with view layout


#1

When we add the image view to the DetailViewController XIB file the size of the view in Interface Builder is misleading in that there is no Nav Bar visible on the top of the ZIB. When I first added the image view I made it take up most of the space between the created date and the bottom toolbar.

The problem is that when this view is really loaded at runtime there is a Navigation Bar at the top and the view we see in the XIB is formatted to fit in the remaining space - effectively we lose 44 points for the Navigation Bar.

There is a great feature in IB to address this…

If you look at the top of the Attributes Inspector for the View there is an option to add “Simulated Metrics” to the visualization of the XIB. If you add Navigation Bar from the Top Bar option the XIB will show you a Nav Bar. This makes it far easier to layout the rest of the view as you now have a UI that is consistent with what you will really have when the view is rendered by the Navigation Controller.

I wish the book had you do this as its easier to see what space you have with this in place. To me I would have someone turn this on at the same time they add the image view in Chapter 12.


#2

You’re right… that’s something we really should add in the fourth edition. Thanks for pointing it out.


#3

Yeah, I figured that out as well after doing the same error. At least I was able to figure that out.


#4

Thanks very much - I was struggling with laying out the clear image button in the silver challenge - this feature helps a lot with laying out properly.