【问题标题】:NSNumberFormatter not displaying rupee symbol only on ipad deviceNSNumberFormatter 仅在 ipad 设备上不显示卢比符号
【发布时间】:2013-01-13 15:40:14
【问题描述】:

我正在使用 NSNumberFormatter 和 NSNumberFormatterCurrencyStyle 在我的通用 iOS 应用中显示应用购买价格。我的位置是印度,格式化程序在我测试的大多数设备(ipad 模拟器、ipad 3 设备、iphone 3gs 设备、iphone 4 设备)中正确显示了印度卢比符号。但是,仅在 ipad 第一代(运行 iOS 5.1.1)上,它显示一个正方形而不是卢比符号。

所有设备都运行它们支持的最新 ios(ipad 3、iphone 4 和 iphone 3gs 上的 iOS 6.0.1;iPad 1 上的 iOS 5.1.1)。

我们用来格式化货币的函数是:

@implementation SKProduct (LocalizedPrice)

- (NSString *)localizedPrice
{
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
    [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
    [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    [numberFormatter setLocale:self.priceLocale];
    NSString *formattedString = [numberFormatter stringFromNumber:self.price];
    [numberFormatter release];
    return formattedString;
}

@end

Update1:​​这似乎只发生在 iOS 5.1 而不是 iOS 6.0 - 我尝试在 ios 6 和 ios 5.1 上的 ipad 模拟器上运行 - 它适用于 ios 6 模拟器,但不适用于 ios 5.1。有没有办法在 ios 5.1 上显示货币符号?

Update2:目前,我检查操作系统版本并仅在 >= 6.0 中显示符号。这就是其他一些应用似乎正在做的事情。

谢谢 阿南德

【问题讨论】:

  • 嗯,我不认为原装 iPad 可以运行 iOS 6...
  • 感谢@DaveDeLong - ipad 1 有 5.1.1。我已经在上面更新了。
  • 谢谢,@H2CO3。我在上面添加了相关代码。

标签: ios nsnumberformatter


【解决方案1】:

如果这不适用于特定版本的 iOS 或设备,您应该提交雷达。

Apple Bug Reporter

【讨论】:

    【解决方案2】:

    你看到了吗?

    这是“通用货币符号”,当格式化程序没有特定的已知符号可供使用时使用。

    iOS 5.1 上的 NSNumberFormatter 没有卢比符号对我来说似乎很奇怪,因为这是一个相当标准的符号。但如果情况确实如此(很抱歉,我这里没有 iOS 5.1 设备可供检查),您可以在格式化字符串中进行查找和替换,以用卢比替换通用货币符号符号。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多