簡體   English   中英

iPhone-NSNumberFormatter問題

[英]iPhone - NSNumberFormatter problem

我正在使用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];

有什么方法可以解決這個問題?

Rhanks

在問題中給出您的評論后,聽起來好像您只需要$貨幣符號,而不管該用戶當前語言環境的定義貨幣符號如何。

這是使用-setCurrencySymbol: NSNumberFormatter類的實例方法完成的。 在您的情況下,您可以執行以下操作:

[currencyStyle setCurrencySymbol:@"$"]; 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM