0

After an upgrade to xcode 7.3.1 my code triggered the infamous "Preferred Max Layout Width" error messages. I didn't manage to fix it for earlier iOS versions, so I finally changed the "builds for" to "iOS 8.0 and later" and the error messages disappeared. It now builds and runs well on iPad, but my UILables are still truncated on iPhone simulations.

Labels are set to "autoshrink: fixed font size". When I choose "autoshrink: minimum font size" instead, the font gets too small, because the view field height isn't extended automatically. I gave the text 10 lines, but it only displays 2 lines and then truncates (it's set to "truncate tail"). How can I achieve to see the full text displayed on iPhones?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
mojomo
  • 109
  • 11
  • can you let us know whether you are using autolayout or autoresizing? also give details.. thanks – Er. Khatri Aug 22 '16 at 16:00
  • @Er. Khatri: I marked both "Use Auto Layout" and "Use Size Classes". Is this what you mean? Sorry, new to this, I just made an app, but I don't really know the lingo yet. Please let me know if you need more information... – mojomo Aug 22 '16 at 22:14

1 Answers1

1

label size do not increment manually, either give constraint to it with top, leading and trailing then it will increment the height of the label accordingly or you can manually increment the height of the label by calculating your string size using

CGSize preferedSize = CGSizeMake(maxWidthYouWant i.e. 320, MAX_FLOAT)
CGSize labelSize = [yourTextString
                    boundingRectWithSize:preferedSize
                    options:NSStringDrawingUsesLineFragmentOrigin
                    attributes:@{
                     NSFontAttributeName : [UIFont systemFontOfSize:14]
                    }
                    context:nil].size;

now you can update your label's height using labelSize.height.

Er. Khatri
  • 1,384
  • 11
  • 29
  • Constraints are set for all four sides, but since it's not working, I should try your code instead. Strange things is that the app used to work perfectly before the 7.3.1 update. – mojomo Aug 23 '16 at 07:44