我有一个包含大量嵌套数据的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
任何建议也将不胜感激。
我刚刚发现了问题所在。我在xib
中设置了单元标识符,但在代码中没有使用它。
在我解决问题之前,它是:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"cell"]];
现在是:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"RegularMatchCell"]];
现在它运行良好。