Why does scanning load localized images too fast?

I have two small problems related, and I think the second is because of the first.

The first is that I have several UIButtons in my application, but there is no text, only background images. These images are localized in 6 languages. The problem is that when editing the views in the storyboard, I see that each button loads the image randomly (sometimes in English, others in Spanish, others in Russian ...). It should be all in English, as I have a key: CFBundleDevelopmentRegion en

See image. I think everything is set up correctly. Do you see something strange? Perhaps this is an Xcode error.

enter image description here

enter image description here

enter image description here

The second problem is that I use automatic layouts. The reason is that the images in these buttons have different sizes depending on the language. Thus, as the size of the intrinsec content changes, the width of the button changes (since there is no limit to the width). The problem is that if I select the button, click the "Size for setting content" button to remove the width limit, it seems to work fine (when I run the application in different languages, the width changes automatically depending on the language), but when the storyboard loads an image in another language (first problem), it seems that the automatic layout automatically adds a width limit, and then when I run the application again, the button width is incorrect in most languages. Do you even understand what is happening?

A very dirty workaround could be to create a UIButton descendant that removes any load with a width limit. I don't know if this works.

I really appreciate your ideas on these issues.

+4
source share
1 answer

This seems to be a bug in Xcode, but it does not affect the final application.

I did the following. Started a new Xcode project. I used storyboards with auto layout. I did not use basic internationalization.

I added 3 buttons to the main view. Then I created 3 images for use with buttons and added them to the resource group. I saved the PNG files in the en.lproj folder using the storyboard. First I got the English version.

Then I went to the project and added French. He created a dialog for all files that, in his opinion, should be localized, and PNG files were included in it. He copied them all to the fr.lproj folder. Then I created the French versions of the PNG files and saved them with the original file names in the fr.lproj folder.

When viewed in Xcode, only one of the buttons was French. The rest were English.

When I ran the application in the simulator, the correct PNGs were used when switching the language.

This is annoying, but does not affect the application when it starts.

Exiting Xcode and restarting it changes which ones are correct, but still do not work correctly. You should probably send a RADAR error with Apple. http://bugreporter.apple.com/

+2
source

Source: https://habr.com/ru/post/1484031/


All Articles