• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
UILabel's sizeToFit - only on re-used cells
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UILabel's sizeToFit - only on re-used cells


  • Subject: UILabel's sizeToFit - only on re-used cells
  • From: Torsten Curdt <email@hidden>
  • Date: Tue, 14 Jan 2014 20:20:53 +0100

I am seeing a weird behavior and I have hard time tracking down what's
going on. Any suggestion on how to pinpoint the problem would be great. I
am running out of ideas.

I have UITableView where I dequeue the cells.

    MyCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell"];

I then setup the cell

    cell.myLabel.text = @"test";
    cell.myLabel.textColor = [UIColor blackColor];

and resize the label to use the proper space for the content

    [cell.myLabel sizeToFit];

Unfortunately `sizeToFit` seems to work only for the re-used cells. So when
I scroll them off screen, the cells coming back on screen are looking fine.
The initial cells don't - they have the labels at their initial size given
in interface builder.

I tried by setting "numberOfLines" or setting a larger frame to shrink from
but I cannot seem to get this to work. It's almost like the first
"sizeToFit" call gets ignored.

Any idea what could be going on?

cheers,
Torsten
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: UILabel's sizeToFit - only on re-used cells
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: RSA and libcrypto
  • Next by Date: Re: UILabel's sizeToFit - only on re-used cells
  • Previous by thread: Re: UIPopoverController and UIToolbar interactions
  • Next by thread: Re: UILabel's sizeToFit - only on re-used cells
  • Index(es):
    • Date
    • Thread