2

親愛なるプログラマーへ

以下のような 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 メソッドが、ペン先の読み込み時に Label に対して 1 回だけ呼び出されることです。

view が popig によって再び表示される場合、すべての customLabel オブジェクトに対してどのメソッドが実行されますか?

私を助けてください。前もって感謝します。

4

1 に答える 1

1

カスタムクラスは必要ありません。

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

于 2011-11-30T12:16:18.473 に答える