简体   繁体   中英

Localization of custom class set in storyboard doesn't work

I added MyTextField , which inherits UITextField .

And,set the textField's custom class set in storyboard to MyTextField .

I localised the textFields's placeholder,but it doesn't work.

If I empty custom class, it works fine.

I can set by code, but could you tell me better choice?

This looks like a bug (unless someone can point me out to a link where such a behavior is detailed as normal by Apple).

What I did was to keep the localizations in the localized storyboard files and manually load them at runtime from there, using NSLocalizedStringFromTable :

MyTextField* myTextField = <find your textField>;
myTextField.placeholder = NSLocalizedStringFromTable(@"PyC-mJ-2Mz.placeholder", @"storyboardName", nil);

The name of the localized string can be found by searching in the localized files for the storyboard. It is a very ugly and manual way of patching the behavior, but at least this way, when (if?) the bug is fixed, all you have to do is to remove that line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM