亲爱的程序员,
我创建一个customLabel类,如下所示:
@interface CustomLabel : UILabel {
NSString *customBundlePath;
}
@implementation CustomLabel
- (void)drawTextInRect:(CGRect)rect
{
NSString *result=[self getLocalvalue:self.text];
[result drawInRect:rect withFont:self.font];
}
-(void)awakeFromNib
{
NSLog(@"%@",self.text);
}
-(NSString *)getLocalvalue:(NSString*)textTolocalize
{
// some code
return localizedText;
}
但是我的问题是,drawTextInRect方法在nib加载时只调用一次Label。
如果视图通过popig再次出现,那么哪个方法将对每个customLabel对象执行?
请帮帮我。
您不需要自定义类。
NSString *someTextString = NSLocalizedString(@"SomeText", @"Description of text for translators")
[myLabel setText:someTextString];
然后您可以从文件中提取字符串并提供适当的本地化文本。
几个有用的链接:
http://www.icanlocalize.com/site/tutorials/iphone-applications-localization-guide/http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial