Advertisement
Guest User

Untitled

a guest
May 23rd, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. //仅展示部分代码
  2. @interface ViewController ()
  3.  
  4. /**
  5. * 原型cell
  6. */
  7. @property (strong,nonatomic) CustomCell *prototypeCustomCell;
  8.  
  9. /**
  10. * 数据源
  11. */
  12. @property (strong,nonatomic) NSArray *dataArray;
  13.  
  14. @end
  15.  
  16. - (void)viewDidLoad{
  17. [super viewDidLoad];
  18. //...
  19. [self.tableView registerClass:[CustomCell class] forCellReuseIdentifier:kCustomCellIdentifier];
  20. self.prototypeCustomCell=[self.tableView dequeueReusableCellWithIdentifier:kCustomCellIdentifier];
  21. }
  22.  
  23. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  24. [self.prototypeCustomCell configurationCell:self.dataArray[indexPath.row]];
  25. [self.prototypeCustomCell setNeedsLayout];
  26. [self.prototypeCustomCell layoutIfNeeded];
  27. CGFloat height=[self.prototypeCustomCell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height+1;
  28. return height;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement