开发者

Localized XIB labels

I took a look in different post and articles, and of course the apple documentation, usually enough for localization purposes.

But, I'm a newbie using IB.

In order to localize the XIB files, I know you can create one version for each language ... but anybody knows if is posible to manage from the UIViewController.

I prefer to manage the localization using the .strings file against to create different XIB files for every new language.

Could w开发者_如何学运维e retrieve the UILabel from the XIB file in the UIViewController (viewDidLoad)?

Thanks for your time,

Ivan


You can't alter a XIB file but by the time viewDidLoad is called, the UILabel if it was part of the XIB file that the view controller loaded will already be part of the view hierarchy. Unless you've directly set an IBOutlet for the UILabel instance, you will have to search through the view hierarchy for a specific marker like a tag perhaps. Once you get the label, it should be a direct assignment of the localized string.

label.text = NSLocalizedString(.., ..);


I didn't test it but can we just subclass UILabel and overload the

- (void) setText:(NSString*) theString

method to

- (void) setText:(NSString*) theString
{
    [super setText: NSLocalizedString (theSrting);
}

Or something like this ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜