【发布时间】:2013-06-15 19:47:49
【问题描述】:
我正在为表格的单元格视图注册一个 XIB。没有什么花哨的,非常简单的小单元格视图,带有几个 UIImageView 和一些 UILabel。事情按预期工作,但是当我滚动时,我会遇到很多口吃/搭便车。我做了一些分析,似乎在 [UITableView _dequeueReusableTyper:withIdentifier:] 上花费了很多时间。我已经注释掉了我的 cellForRowAtIndexPath 方法中的所有代码,除了简单的出列和返回单元格,而且口吃仍然存在。所以罪魁祸首确实是这个出列调用堆栈。但我不确定如何优化它以使其顺利运行,而不是简化我的 XIB 中的单元格视图,这可能不是一个选项(或一个困难的选项)。我在这里错过了什么我应该尝试的东西吗?
出队代码:
UIMyTableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"MyTableCell"];
if (cell == nil)
{
UINib *nib = [UINib nibWithNibName:@"UIMyListTableCellView" bundle:nil];
[table registerNib:nib forCellReuseIdentifier:@"MyTableCell"];
}
cell = [table dequeueReusableCellWithIdentifier:@"MyTableCell"];
【问题讨论】:
-
您在单元格中放入什么样的图像 - 什么尺寸/分辨率?
-
你能发布一些代码吗?出队的发生方式可能存在错误。
-
小图像。一张图片是 100x100 像素,还有两张较小的 30x30 像素。
-
我的出队代码:
UIMyTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"MyTableCell"]; if (cell == nil) { UINib *nib = [UINib nibWithNibName:@"UIMyListTableCellView" bundle:nil]; [table registerNib:nib forCellReuseIdentifier:@"MyTableCell"]; } cell = [table dequeueReusableCellWithIdentifier:@"MyTableCell"];
标签: ios uitableview