sizeToFit behavior changed for iOS 6.0?

Discussion in 'iOS Programming' started by samdev, Sep 19, 2012.

  1. samdev macrumors regular

    Sep 16, 2011
    I just downloaded XCode 4.5 and iOS 6.0, and compiled it for my app, and noticed when running iOS 6.0
    on the simulator, the behavior of "sizeToFit" has changed.

    I'm using a UILabel with text that changes in size over time (a scoreboard), e.g:

    [self.myLabel setText:myString];
    [self.myLabel sizeToFit];
    And my score no longer fits. I can't even see it.

    Before, the label would "expand" to fit the text, but now, the label only "contracts" to fit.
    It does not expand anymore.

    What's up with this change? :confused:
    How do you fit a UILabel with text that can grow or contract?
  2. 12991 macrumors member

    Feb 3, 2007
    has anyone found a fix for this yet? I am running into issues. I want to know if its io6 related or me related
  3. ArtOfWarfare macrumors G3


    Nov 26, 2007
    Why wouldn't you just make the UILabel as large as possible? sizeToFit will shrink it if the label is larger than necessary, and in the event that its too large, well, tough luck, because the screen size is only so big?

    (I've never used sizeToFit, so my understanding of it might be... Wrong.)
  4. Reason077 macrumors 68020


    Aug 14, 2007
    What ArtOfWarfare said. Just size your UILabels with the maximum amount of space you have available for the label, and call sizeToFit if you want to shrink it.

    If you need to calculate the size of a UILabel for a given string, try sizeThatFits:

Share This Page