我有一个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
任何建议也将受到赞赏。
答案 0 :(得分:0)
我刚刚发现了问题所在。我在xib
中设置了单元格标识符,但未在我的代码中使用它。
在我解决问题之前,它是:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"cell"]];
现在是:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:[NSString stringWithFormat:@"RegularMatchCell"]];
现在工作正常。