Xcode Interface Builder Tips

A couple of quick tips when using Interface Builder that I picked up whilst watching the WWDC 2013 videos. It turns out that whilst these are new to me they are not actually new. I do not know when these were introduced but they work fine in the current public release of Xcode (v4.6.3 at time of writing).

Selecting An Object

The first tip addresses an annoying situation when you are trying to select a specific object in the view hierarchy. Consider a table view controller containing a prototype cell view which itself contains a number of labels:

It can be tricky to click-on a specific object such as the table view cell or the table view without getting one of the UILabel objects by mistake. One option is to find the object you want in the document navigator window:

However a much easier way is to control-shift click in the scene. This displays a popup window with the full view hierarchy for wherever you click. For example, in the screenshot below I control-shift clicked with the mouse pointer over the “Country” UILabel:

It is now simple to select the table view cell or the table view without resorting to the document browser.

Viewing Layout Metrics

The second quick tip allows you to view the relative spacing and positioning of a view. With a view selected, press the Option key and move the mouse pointer over the scene in Interface Builder. As you move around a set of guides are displayed showing the number of pixels from the selected view to the view you are currently hovering over. For example, with the Country UILabel selected and the pointer over the table view the following is displayed:

Useful for those situations when you want to align and carefully position a number of views.

Never miss a post!

iOS Size Classes Cheat Sheet

Subscribe and get my free iOS Size Classes Cheat Sheet

Success! Now check your email to confirm your subscription and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

OK! Check your inbox (or spam folder) for an email to confirm your details and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
Archives Categories