首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏DannyHoo的专栏

    cell高度的缓存1——利用字典进行缓存

    对于cell高度固定的页面来说这个很好办直接在heightForRowAtIndexPath方法中返回固定的一个数值就行。然而对于cell高度不固定的页面来说却需要我们开发人员计算出cell的高度。 笔者之前通常会会将计算cell高度的代码放在heightForRowAtIndexPath方法中,看代码: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ TopicModel * model = self.dataSource[indexPath.row return cellHeight; } 上面的代码虽然能计算出cell的高度实现想要的效果,可会有一个耗性能的问题:即使之前计算过某个cell的高度,在这个cell在此展示出来的时候还会再次调用heightForRowAtIndexPath 代码: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    77010发布于 2018-09-13
  • 来自专栏一“技”之长

    iOS开发中行高灵活可变的UITableView的性能优化

    方法会重复执行好多次,首先,并且heightForRowAtIndexPath方法的执行机制在不同版本的iOS系统还会有很大不同。 以iOS9为例,一行cell要展示在屏幕上,至少要执行5遍TableView的heightForRowAtIndexPath方法: TableView配置部分: ① 当TableView视图即将展现在屏幕上时 二、对UITableView可变行高的计算方式进行优化         通过前面的分析,可以理解如果将复杂的计算代码写在heightForRowAtIndexPath方法中,代价将是非常惨重的。 这个值设置之后,开发者无需设置rowHeight属性,也不需要实现heightForRowAtIndexPath方法,系统会自动根据UITableViewCell中contentView的约束来计算自己的行高 方法,heightForRowAtIndexPath方法会以懒加载的方式执行,只有在cell将要展现在屏幕上时heightForRowAtIndexPath方法才会被执行,这也可以有效减小由于高度计算带来的性能负担

    3K20发布于 2018-08-15
  • 来自专栏码客

    iOS 设置tableViewCell的高度

    PingjiaTableViewCell; self.offscreenCells["PingjiaTableViewCell"] = cell; 计算高度 func tableView(tableView: UITableView, heightForRowAtIndexPath self.tableView.rowHeight = UITableViewAutomaticDimension; 去掉下面的代理方法 func tableView(tableView: UITableView, heightForRowAtIndexPath

    3.1K30发布于 2019-10-22
  • 来自专栏iOS逆向与安全

    iOS设置视图圆角失效的解决方案

    2)减少heightForRowAtIndexPath代理中的计算量(cell的高度计算)。 3.2 减少heightForRowAtIndexPath代理中的计算量: ① 由于每次tableView进行update(更新)都会对每一个cell调用heightForRowAtIndexPath代理取得最新的 如果表格的所有cell高度都是固定的,那么去掉heightForRowAtIndexPath代理,直接设置tableView的rowHeight属性为固定的高度。

    2.9K10编辑于 2022-08-22
  • 来自专栏DannyHoo的专栏

    cell高度的缓存2——利用模型属性缓存

    此时heightForRowAtIndexPath方法中的代码为: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    66520发布于 2018-09-13
  • 来自专栏ShaoYL

    iOS-UI控件之UITableView(三)- 自定义不等高的cell

    mainScreen].bounds.size.width - 20; } 设置tableView的cell估算高度 // 告诉tableView所有cell的估算高度(设置了估算高度,就可以减少tableView:heightForRowAtIndexPath self.tableView.estimatedRowHeight = 200; 在代理方法中计算cell的高度 XMGStatusCell *cell; - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    1.1K100发布于 2018-05-11
  • 来自专栏向治洪

    iOS AutoLayout全解

    如下面是计算UITableView高度的代码: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath indexPath.row]; [cell.t sizeToFit]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath indexPath.row]; [cell.t sizeToFit]; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath return cell; } #pragma mark - UITableViewDelegate - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    6.3K60发布于 2018-02-06
  • 来自专栏iOS122-移动混合开发研究院

    有了Auto Layout,为什么你还是害怕写UITabelView的自适应布局?

    .可能你会说: 顶部给个非微博正文区域给个固定高度;文字区域动态计算出高度;图片部分,图片高度固定,根据数量动态计算高度;转发部分同理;然后根据数据在tabelView的代理方法 tableView:heightForRowAtIndexPath 但是又要求完全显示的设计,最复杂的不在于实现,而在于后期的迭代.可变字段越多,迭代越复杂.如果连显示方式都改了,那就基本等于重做了几遍. cell高度计算有坑: 难以理解的诡异问题 在 tableView:heightForRowAtIndexPath 关于这个话题,比较易犯的错误是,竟然有开发者在 tableView:heightForRowAtIndexPath: 中调用 tableView:cellForRowAtIndexPath: 来获取cell 核心代码片段: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

    1.4K60发布于 2018-01-02
  • 来自专栏华仔的技术笔记

    提升UITableView性能-复杂页面的优化

    = 首先要确定的是,在iOS中,系统会先调用“tableView:heightForRowAtIndexPath:”获取每个Cell即将显示的高度,从而确定整个UITableView的布局。 property(assign, nonatomic) CGFloat cellHeight; //计算高度 (void)calculateCellHeight; @end 这样,就不用在“tableView:heightForRowAtIndexPath

    1.3K50发布于 2018-05-17
  • 来自专栏服务端技术杂谈

    【死磕iOS】处理不等高TableViewCell的小花招

    UITableViewCellSelectionStyleNone; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath UITableViewCellSelectionStyleNone; return cell; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath 重要的事情说三遍… (CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath

    1.7K80发布于 2018-04-16
  • 来自专栏iOS 音视频接入-TRTC

    iOS 集成TUIKit后撤回消息cell高度有问题?

    endUpdates]; [self scrollToBottom:YES]; } image.png 代码 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    84510发布于 2020-12-25
  • 来自专栏娱乐心理测试

    ios 开发常用技巧

    sharedApplication].idleTimerDisabled = YES; 6.隐藏某行cell - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    77930发布于 2018-06-13
  • 来自专栏Helloted

    常用代码/Code

    numberOfRowsInSection:(NSInteger)section{ return 10; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    69120编辑于 2022-06-07
  • 来自专栏日常技术分享

    iOS TableView 优化

    优化就注意几点 1.TableView性能影响最大的是每个cell高度的获heightForRowAtIndexPath,这个函数会调用很多次,对于不是固定高度的cell,每次都需要去计算。

    1K20发布于 2021-05-19
  • 来自专栏我只不过是出来写写iOS

    iOS 多section瀑布流实现(swift)

    代理实现 2.1 必须实现代理方法 /// collectionItem高度 func heightForRowAtIndexPath(collectionView collection: UICollectionView

    2.2K10发布于 2020-05-18
  • 来自专栏技术之路

    【swift学习笔记】三.使用xib自定义UITableViewCell

    NSIndexPath) { print("\(indexPath.row)") } func tableView(tableView: UITableView, heightForRowAtIndexPath

    2.5K70发布于 2018-01-31
  • 来自专栏ShaoYL

    iOS-UI控件之UITableView(二)- 自定义不等高的cell

    在这个方法中返回indexPath位置对应cell的高度 /** * 返回每一行cell的具体高度 */ - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    1.1K110发布于 2018-05-11
  • 来自专栏Alice

    效果类似于label从下往上滑(采用uiTableView实现)

    numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    1.5K50发布于 2018-02-01
  • 来自专栏大宇笔记

    商城分类页面自适应标题,自适应换行。

    +10+row*30;     cell.frame = rect; return cell; } -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    1.6K20发布于 2019-01-15
  • 来自专栏学海无涯

    iOS开发之有间距的UITableViewCell

    numberOfRowsInSection:(NSInteger)section { return 1;} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath

    2.1K61发布于 2018-05-03
领券