可以使用继承或者类别来重载方法来进行实时刷新,在一些标签需要进行静态语言切换的时候可以用这个方法
这里使用类别方法来处理
//send the sigle
[[NSNotificationCenter defaultCenter] postNotificationName:@"LangeuageChange" object:[[NSString stringWithFormat:@"%d", iLangCode] retain]];
@interface UILabel(LanguageDeal)
- (void) setLangText:(NSString *)intext;
- (void) reSetText:(NSNotification *)notify;
@end
@implementation UILabel (LanguageDeal)
- (void) setLangText:(NSString *)intext
{
self.text = intext;
//wait for the signal
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reSetText:) name:@"LangeuageChange" object:nil];
}
- (void) reSetText:(NSNotification *)notify
{
NSString * szcode = (NSString *)[notify object];
int code = [szcode intValue];
NSLog(@"reset get %d", code);
if (code == 0)
{
self.text = @"000";
}
else
{
self.text = @"111";
}
}
@end