How to locate images and views in Interface Builder

After explaining how to locate our strings in Xcode , it is easy to see now how - by applying the same technique - to locate and view images / interfaces created with Interface Builder.

Locate graphics resources

The process, as mentioned, is the same, if we have an image already included in our resources, or they insert a new one, and we want to "locate" - that is, to manage two or more images based on the languages ​​supported - just click the button Right image ( Adium.png in this example) and select Get Info:

Make File Localizable we click in the lower left.

We click on Add and insert Localization Italian :

In order to obtain:

esattamente come accadeva con il testo: Our image is moved (physically, one of the rare times when that happens nell'alberatura Xcode is reflected on the filesystem) under virtual folders English.lproj and Italian.lproj exactly as happened with the text:

contiene una stessa versione dell'immagine. At this point each of the folders English.lproj and Italian.lproj contains the same version of the image. This image is manipulated in Interface Builder, where we will see - by default - the English version.
At this point, just overwrite one (or both files Adium.png ) to obtain a location of images "flash".

Locate the files XIB

Even the interfaces built with Interface Builder can be located in their entirety, when it is deemed necessary. ) con interfaccia XIB , lo selezioniamo, scegliamo Get Info dal menu contestuale, rendiamo il file localizzabile, aggiungiamo la localizzazione in italiano: The procedure is identical to that performed with the graphical capabilities: add a ViewController (eg infoViewController ) XIB interface, we select it, choose Get Info from the contextual menu, give the file localizable, add the Italian localization:

ViewController

Clicking Italiano or Italian will open Interface Builder! ) all'interno della classica cartella Classes . This time, the filesystem, you will notice that you have created two directories ( English.lproj and Italian.lproj ) within the classical Classes folder. Both will have their files infoViewController.xib . The comfort in this, clearly resolved in the code, and when we're going to instantiate our controller code we will have a "clean" like this:

1
2
[ InfoViewController alloc ] ; InfoViewController * info = [InfoViewController alloc];
info.view ] ; [Self.view addSubview: info.view];

As you can see there is no trace of any statement concerning the location, totally managed by the system. The two interfaces, of course, can be completely different, as are in effect as two separate XIB file.

There are no comments for this post

Leave a comment

XHTML TAG PERMIT: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> INSERTION CODE:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Stop SOPA