1

在我的 Cocoa 应用程序中,我使用以下内容在标签中设置数字格式

NSNumberFormatter *numberFormatter =
      [[[NSNumberFormatter alloc] init] autorelease];
     NSMutableDictionary *newAttrs = [NSMutableDictionary dictionary];

    [numberFormatter setFormat:@"###,##0;(###,##0)"]; 
     [newAttrs setObject:[UIColor redColor] forKey:@"NSColor"];
     [numberFormatter setTextAttributesForNegativeValues:newAttrs];

     [[datacellR1C2 cell] setFormatter:numberFormatter];

当我使项目适应 iOS 时,我在使用它时遇到错误。我收到错误消息“未找到 setFormat”</p>

我应该在使用 UIKit.h 构建的 iOS 应用程序中使用什么?

4

1 回答 1

2

setFormat:方法在 iOS 中不可用(请参阅NSNumberFormatter 类参考)。
请改用setPositiveFormat:andsetNegativeFormat:方法。

于 2012-07-06T13:23:51.960 回答