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,343
  • 2
  • 20
  • 39
UGandhi
  • 518
  • 1
  • 8
  • 28
  • 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

2 Answers2

1

try this

    dispatch_async(dispatch_get_main_queue(), ^{ 
[cell.userImage updateConstraints]; 
[cell layoutIfNeeded]; 
});
Jigar
  • 1,801
  • 1
  • 14
  • 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