由于NSDictionary嵌套数据,UITableView滚动速度慢?

时间:2013-02-18 20:28:53

标签: uitableview nsarray nsdictionary xib

我有一个NSDictionary,有很多嵌套数据。所有这些数据都会在UIViewController中加载一次,然后重新加载UITableView,使用此数据填充单元格的标签,这些标签在单独的xib中设置。所有加载过程都发生得非常快,但我的UITableView滚动变得非常慢。我首先想到的是每次分配一个单元格时都可以加载xib,所以我测试了默认的UITableViewCell而不是加载它,但没有任何改变。 这个问题可能是由我访问数据的方式引起的吗?我正在做以下事情:

NSDictionary *match = dictionaryMatches[@"dates"][indexPath.section][@"matches"][indexPath.row];

homeTeamAbbreviationLabel.text = match[@"home"];
visitorTeamAbbreviationLabel.text = match[@"visitor"];
matchTimeLabel.text = match[@"time"];
leagueLabel.text = match[@"league"];

homeNameLabel.text = match[@"home_name"];
visitorNameLabel.text = match[@"visitor_name"];

此代码位于- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

任何建议也将受到赞赏。

1 个答案:

答案 0 :(得分:0)

我刚刚发现了问题所在。我在xib中设置了单元格标识符,但未在我的代码中使用它。

在我解决问题之前,它是:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"cell"]];

现在是:

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"RegularMatchCell"]];

现在工作正常。

相关问题