iOS Storyboard可本地化的string在UILabel子类中不起作用

我正在使用新的iOSfunction来翻译故事板( http://developer.apple.com/library/ios/#referencelibrary/GettingStarted/RoadMapiOS/chapters/InternationalizeYourApp/InternationalizeYourApp/InternationalizeYourApp.html )

这个解决scheme的问题,它不适用于我的UILabel子类。

这里是我的UILabel子类的代码:

。H:

#import <UIKit/UIKit.h> @interface LabelThinText : UILabel - (void)awakeFromNib; -(id)initWithFrame:(CGRect)frame; @end 

.m:

 @implementation LabelThinText - (void)awakeFromNib { [super awakeFromNib]; [self setFont:[UIFont fontWithName:@"Raleway-Light" size:[[self font] pointSize]]]; } -(id)initWithFrame:(CGRect)frame { id result = [super initWithFrame:frame]; if (result) { [self setFont:[UIFont fontWithName:@"Raleway-Light" size:[[self font] pointSize]]]; } return result; } @end 

我想我错过了一些从我的Storyboard.strings文件中获得自动翻译。

任何人有一个想法?

谢谢 !

我遇到了同样的问题,出于同样的原因,在标签中设置自定义字体。 不过,我的策略比较一般。 我的自定义字体是类似Helvetica的,所以我在IB中使用了Helvetica Neue作为占位符字体。 UILabel子类将其转换为我的自定义字体,保留字体大小和重量,所以我可以通过IB控制所有的字体。

这使我的翻译错误(我认为这是一个错误)更容易的解决方法。 我在viewDidLoad中recursion遍历所有视图,并且映射所有UILabel字体(如果它们与占位符字体相匹配),而在我的情况下,它们与UIButton相同。

你提交了一个错误?

遇到同样的问题,我是这样解决的:

放下你的自定义类,并在你的情况下在UILabel上创build一个类别UILabel + ThinText:

 - (void) setThinText:(BOOL)thinText { if (thinText) { [self setFont:[UIFont fontWithName:@"Raleway-Light" size:[[self font] pointSize]]]; } } 

在故事板中,select您的标签,selectIdentity Inspector并添加以下用户定义的运行属性

Keypath :thinText – types :布尔值 – :选中

我也有这个问题。 我解决它在每个ViewController设置自定义字体。 让我给你看一个例子:

  CustomViewController.h @interface CustonViewController @property (strong, nonatomic) IBOutlet UILabel* someLabel; @end 

CustomViewController.m

 - (void)viewDidLoad { [self setUoFonts]; } - (void)setUpFonts { self.someLabel.font = [UIFont fontWithName:@"AmaticSC-Regular" size:self.someLabel.font.pointSize]; } 

就是这样! 你将有你的翻译和你的自定义字体。

记得从StoryBoard中删除自定义类。