Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //仅展示部分代码
- @interface ViewController ()
- /**
- * 原型cell
- */
- @property (strong,nonatomic) CustomCell *prototypeCustomCell;
- /**
- * 数据源
- */
- @property (strong,nonatomic) NSArray *dataArray;
- @end
- - (void)viewDidLoad{
- [super viewDidLoad];
- //...
- [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:kCustomCellIdentifier];
- self.prototypeCustomCell=[self.tableView dequeueReusableCellWithIdentifier:kCustomCellIdentifier];
- }
- -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- [self.prototypeCustomCell configurationCell:self.dataArray[indexPath.row]];
- [self.prototypeCustomCell setNeedsLayout];
- [self.prototypeCustomCell layoutIfNeeded];
- CGFloat height=[self.prototypeCustomCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height+1;
- return height;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement