美文网首页IOS三人行
让TableView 流畅起来,拒绝卡顿

让TableView 流畅起来,拒绝卡顿

作者: 飞翔的小骑兵 | 来源:发表于2016-04-22 10:30 被阅读1988次

TableView优化10条

  1. 避免 cellForRowAtIndexPath 中使用 addsubview 加载众多view 会引起严重卡顿
  2. 自定义UITableViewCell 时一般这样处理
    static NSString *ID = @"HomeActivityCell3";
     HomeActivityCell3 *cell = [tableView   dequeueReusableCellWithIdentifier:ID];
     if (cell == nil) {
                cell = [[[NSBundle mainBundle] loadNibNamed:ID owner:nil options:nil] objectAtIndex:0];
            }

Identifier 未标识,cell不会被重用


Paste_Image.png

3.尽量使所有的view opaque,包括cell自身
4.避免渐变,图片缩放,后台选人
5.缓存行高
6.如果cell内现实的内容来自web,使用异步加载,缓存请求结果
7.使用shadowPath来画阴影
8.尽量不适用cellForRowAtIndexPath:如果你需要用到它,只用一次然后缓存结果
9.使用正确的数据结构来存储数据
10使用rowHeight, sectionFooterHeight和 sectionHeaderHeight来设定固定的高,不要请求delegate

相关文章

网友评论

    本文标题:让TableView 流畅起来,拒绝卡顿

    本文链接:https://www.haomeiwen.com/subject/blqxrttx.html