【问题标题】:Tableview cells does not display data when in integer format表格视图单元格在整数格式时不显示数据
【发布时间】:2010-10-05 10:56:01
【问题描述】:

我的应用程序有一个 sqlite 数据库,我正在使用 executeQuery 方法检索和插入数据。

问题

我无法分配表格视图的整数值单元格。它不显示整数格式的数据。我想将整数值存储到表格视图中并显示排序整数 数据给用户。

我在这里发布我的代码

1) 在 vi​​ewDidLoad 中,我已从数据库表“dummy”中检索整数值并将其放入 NSArray“Scores”中

2) 我已经为表格视图的“cellForRowAtIndexPath”方法中的单元格分配了一个整数类型的“highscore”值。请注意,将此数据转换为 NSString 不允许排序。

但是当我运行它时,表格单元格中没有显示任何数据。

1)

NSString *myDBnew = @"/Users/taxsmart/Documents/sqlite/atest.sql";

数据库 = [[Sqlite alloc] init];

[数据库打开:myDBnew];

Scores = [数据库 executeQuery:@"SELECT * FROM dummy ORDER BY highscore DESC;"];

2)

cell.textLabel.text = [[Scores objectAtIndex:indexPath.row] valueForKey:@"highscore"];

怎么了?

请提出您的建议。欢迎您提出建议。

【问题讨论】:

    标签: objective-c cocoa-touch uitableview ios4


    【解决方案1】:

    您必须将NSString* 分配给cell.textLabel.text。只需将 int 嵌入到 NSString 中即可。

    NSInteger highscore = [[Scores objectAtIndex:indexPath.row] valueForKey:@"highscore"];
    cell.textLabel.text = [NSString stringWithFormat:@"%d", highscore];
    

    【讨论】:

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