1

I am changing the cell height with regard to available image height of different data and updating the constraints of the cell of UITableViewCell.

I have a number of pages in my app which is same as friends in Facebook and each page includes 1 or more feeds.

Now, the problem is that when I am selecting a number of pages to send the data on UITableViewCell, it is not reflecting the updated cell height. It is taking a default value.

But, on the other hand, when I am selecting a single page to send the data, it is coming updated.

Although, the calculated cell height for both the cases is coming same. (Checked by debugging and printing the log).

I am using this code to update the Image height constraints.

[cell.userImage updateConstraints];
[cell layoutIfNeeded];

Please suggest any solution

Tejas Ardeshna
  • 4,213
  • 2
  • 17
  • 39
UGandhi
  • 485
  • 1
  • 7
  • 25
  • 1
    try this dispatch_async(dispatch_get_main_queue(), ^{ [cell.userImage updateConstraints]; [cell layoutIfNeeded]; }); – Jigar Feb 28 '17 at 14:08
  • Have you read this: http://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-variable-row-heights ? – koen Feb 28 '17 at 17:22
  • @Jigar It helped. Thank You. – UGandhi Mar 01 '17 at 06:16
  • @Koen Yes, I had read this link before. Even, I had already done everything which is mentioned in this link. Thank you for the reference. – UGandhi Mar 01 '17 at 06:17

2 Answers2

1

try this

    dispatch_async(dispatch_get_main_queue(), ^{ 
[cell.userImage updateConstraints]; 
[cell layoutIfNeeded]; 
});
Jigar
  • 1,741
  • 1
  • 13
  • 29
0

It happens because there must be so many running on running thread, it would be better to put this on different thread.

Try using,

 dispatch_async