0

I have a case where text in a UITextView is not line broken correctly in iOS 7. It works fine in iOS 6. The text view, self.textLabel (not the best of variable names but I'm stuck with it), is defined in IB (w:120 h:42 & System Font 13) and populated in the following code:

- (id)initWithIcon:(UIImage*)icon labelText:(NSString*)labelText;
{
    self = [super initWithClass:[self class]];

    self.textLabel.text = [labelText uppercaseString];
    [self.button setImage:icon forState:UIControlStateNormal];

    return self;
}

Links to explanatory screens shots below.

The following texts work fine (in iOS 6 & iOS 7):

"ACCESSOARER & KOSMETIKA" result in: Line 1:"ACCESSOARER &" Line 2:" KOSMETIKA "

"ELEKTRONIK & TELEFONI" result in: Line 1:" ELEKTRONIK & " Line 2:" TELEFONI "

But this text:

RESOR & TRANSPORT results in "SOR & TRANSPO" in iOS 7.

In iOS 6 it results in Line 1: " RESOR & " Line 2:" TRANSPORT "

iOS 6 screenshot

iOS 7 screen shot

MickeDG
  • 404
  • 5
  • 18
  • Had a similar issue recently, ended up tweaking a bit the NSLayoutConstraints of the label. Could this help ? – Nerkatel Apr 03 '14 at 16:44
  • @Nerkatel - Thanks for the suggestion but no, I don't think so since Autolayout is not on here. – MickeDG Apr 04 '14 at 07:01
  • I found a piece of code by @Emmanuel here [link] http://stackoverflow.com/questions/22300297/uitextview-count-lines-not-working-as-intended which sort of verifies my problem. It returns 2 where it should except for "RESOR & TRANSPORT"... – MickeDG Apr 04 '14 at 10:55

2 Answers2

0

Have you tried this answer? It seems like bounds of text in your UITextView are wrong

Community
  • 1
  • 1
Crostek
  • 56
  • 5
0

This was finally resolved after I filed a Bug Report. I had defined a category on UILabel where I was overriding (CGSize)intrinsicContentSize. So problem disappeared after removing the category. And nothing else broke - makes me wonder why I had put in that category :)

Apple answer:

This is happening because you have a category on UILabel and are overriding:

-(CGSize)intrinsicContentSize {
   CGSize s = [super intrinsicContentSize];
   s = CGSizeMake(s.width, s.height + 4);
   return s;
}
MickeDG
  • 404
  • 5
  • 18