iOS设置行高的多种方式以及优先级区分

来源:互联网 发布:易语言取中间文本源码 编辑:程序博客网 时间:2024/06/04 18:07

优先级:
代理方法中的优先级如下,从高到低
(1).heightForRowAtIndexPath
(2).self.tableView.rowHeight
(3).storyboard中TableView的rowHeight
(4).storyboard中TableViewCell的rowHeight

  • 代理方法中设置优先级
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {    if (indexPath.row % 2 == 0) {        return 521;    } else {        return 1314;    }}
  • 代码设置
self.tableView.rowHeight = 64;
  • storyboard中TableView的rowHeight
    这里写图片描述

  • storyboard中TableViewCell的rowHeight
    这里写图片描述

0 0
原创粉丝点击