I have an app that uses localization, I need to add one more language, I want to display two different language images of same name in one xib file, the xib file is not localized as I am localizing the images. Can it be done using interface builder, without writing any code?

有帮助吗?

解决方案 2

Add the images to your localized subdirectories in your project (en.lproj, es.lproj, etc.) and iOS will pick up the correct image when it unarchives the localized xib file.

Xcode can do this for you automatically: Just select the resource you want to localize (an image, xib file, etc.), display the File Inspector pane, and then click the Localize button.

(As a side note, it's a bad practice to localize a high number of images. You should remove text from images and choose them so they are "neutral" and "understandable" in every region of the world. Your app size will thank you for it.)

其他提示

enter image description here

You can add one more language by click on + button.Hope this will help you.But you have to make multiple XIB's as you are saying to set the images only in one XIB i think it is not possible.

To do it without code you must localize the xibs, otherwise you will require code from you or others and some configuration. It's easier as follows:

Assuming you have added already localizations to the project (you can do it in Project > Info tab) you just need to select the image in the project tree and check the desired localizations in the right sidebar (cmd-alt-1, localizations).

Replace the image in each *.lproj directory with the localized version. Then in your viewDidLoad use -[UIImage imageNamed:] as usual to load an image into the xib image view or whatever you are doing.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top