Using sizeToFit in iOS 7 on a label resets its height when navigating away from the view controller

142 views Asked by At

I have looked everywhere for a similar situation to this, but could not find one.

I have a table view controller set up with dynamic prototypes. Inside of the cell, I have a label. This label can have multiple lines, therefore I set the number of lines to 0 and the line breaks to word wrap.

On my viewDidLoad method, I call a function to pull some data from my cloud service provider. In my (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath function, I set my label's text to what was return from the cloud, then I auto fit the size of the label using sizeToFit.

This works perfectly when the application first loads. The problem is when I navigate away from the table view controller. The label that I set sizeToFit, gets resized to its initial height, which was defined in IB.

  • So for example, the initial height of the label is 18 (set in IB).
  • The data gets returned from the cloud.
  • The label wraps the text to 2 lines.
  • I resize the label and it becomes 36.
  • I navigate away from the view controller.
  • The height of the label gets set back to 18.

Does anyone have any thoughts on this? Possible bug?

0

There are 0 answers