0

NSNumberFormatter を使用して通貨形式の文字列を作成しています。ほとんどのデバイスではすべて正常に動作しますが、韓国語のデバイスなどの一部のデバイスでは、$ 記号が四角形として表示されます。

NSNumberFormatter *currencyStyle = [[NSNumberFormatter alloc] init];
[currencyStyle setFormatterBehavior:NSNumberFormatterBehavior10_4];
[currencyStyle setNumberStyle:NSNumberFormatterCurrencyStyle];
NSNumber *amount = [NSNumber numberWithInteger:moneyAmount];
NSString *amountString =  [NSString stringWithFormat:@"%@", [currencyStyle stringFromNumber:amount]];
[currencyStyle release];

この問題を解決する方法はありますか?

ランクス

4

1 に答える 1

2

$質問のコメントを考えると、ユーザーの現在のロケールに対して定義されている通貨記号が何であれ、通貨記号が必要なように思えます。

これは、クラスの-setCurrencySymbol:インスタンス メソッドを使用して行われます。NSNumberFormatterあなたの場合、次のことができます:

[currencyStyle setCurrencySymbol:@"$"]; 
于 2010-10-10T01:53:50.233 に答える