0

Assume we have UITableView created in storyboard with prototype cells, it is required to change the structure of table cells (adjusting frames of labels in cell content) based on some calculations at loading the view, currently I change each cell in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

after using dequeueReusableCellWithIdentifier: to load table cell,

but this is not efficient as each cell has to be modified individually, it would be much better if we could modify a loaded cell once and reuse the modified cell .

Any ideas ?

This could be useful:

Prefilling the UICollectionView cell reuse queue

UITableView dequeueReusableCellWithIdentifier Theory

Community
  • 1
  • 1
Amr Lotfy
  • 2,937
  • 5
  • 36
  • 56
  • use custom cell and create xib for each cell and use if statement for each cellforrowindexpath...you can load different cells – AyAz Feb 07 '16 at 07:38
  • @khaskheli_ayaz I need to dynamically change labels inside cell at view load and I need to do this according to some calculations and I need to do it once at view did load and not each time I dequeue a cell, thank you. – Amr Lotfy Feb 07 '16 at 07:41
  • 1
    Can you use autoresizing cells? That way each cell can calculate the size themselves using autolayout, and the table will use them with the correct size. – Eli Braginskiy Feb 07 '16 at 08:24
  • 1
    @BlueGene Each cell has labels, and for each label `origin.x` and `width` have to be aligned to code-created labels in another view, creating constraints would be good, I am working on some way to reuse the modified cell, and this could help, I will consider that, Thank you very much ! – Amr Lotfy Feb 07 '16 at 08:36

0 Answers0