UILabel sizeToFit is shrinking the Label width

  • Hi All, I'm working on an app where the position of the subviews
    depends on the sizes of the others. I have implemented a method to
    reallocate the components. As part of the interface I have somes
    UILabel that loads the text to display dynamically, the length of the
    text is variable and I'm using [label sizeToFit] method to properly
    display it (previously I set label.numberOfLines = 0), until here
    everything works ok.

    My problem began with the rotation, in the method
    didRotateFromInterfaceOrientation: I call the reallocation method and
    everything works, with the exception that the labels are getting
    smallers with each rotation. Without calling sizeToFit I don't have
    this problem, but how in landscape orientation the label needs less
    lines to display the text the distances between the controls increase.

    The font size and minimum font size are the same value, I
    enable/disable autoshrink, I try the different autosizing masks,
    getting the same problem, any idea?.

    --
    Regards,
    Takeichi Kanzaki Cabrera
    Linux Registered User #308138

    If you want to be original,
    be yourself.
  • I solved it making the label as wide as its superview before calling sizeToFit.

    Best regards.

    On Tue, Jun 26, 2012 at 12:59 PM, Takeichi Kanzaki Cabrera
    <tkanzakic...> wrote:
    > Hi All, I'm working on an app where the position of the subviews
    > depends on the sizes of the others. I have implemented a method to
    > reallocate the components. As part of the interface I have somes
    > UILabel that loads the text to display dynamically, the length of the
    > text is variable and I'm using [label sizeToFit] method to properly
    > display it (previously I set label.numberOfLines = 0), until here
    > everything works ok.
    >
    > My problem began with the rotation, in the method
    > didRotateFromInterfaceOrientation: I call the reallocation method and
    > everything works, with the exception that the labels are getting
    > smallers with each rotation. Without calling sizeToFit I don't have
    > this problem, but how in landscape orientation the label needs less
    > lines to display the text the distances between the controls increase.
    >
    > The font size and minimum font size are the same value, I
    > enable/disable autoshrink, I try the different autosizing masks,
    > getting the same problem, any idea?.
    >
    > --
    > Regards,
    > Takeichi Kanzaki Cabrera
    > Linux Registered User #308138
    >
    > If you want to be original,
    > be yourself.

    --
    Regards,
    Takeichi Kanzaki Cabrera
    Linux Registered User #308138

    If you want to be original,
    be yourself.
previous month june 2012 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
Go to today