kohaXun
kohaXun

Reputation: 147

TTTAttributedLabel linebreakmode broken in iOS6

If I set linebreakmode to truncation tail in the TTTAttributedLabel Example App "Espresso" everything looks like it should be in iOS 5 Simulator but if I run the App in iOS 6 Simulator the text gets truncated after the first line although the text goes over 3 lines. Number of lines are set to zero. Did I miss something? After I noticed this behavior in the Espresso App I can stop worrying about the brokeness of the code in my own app. Any suggestions? Thanks!

Upvotes: 3

Views: 1998

Answers (5)

soGa
soGa

Reputation: 1

You can have a try.

NSMutableAttributedString * mutableAttributedString = [[NSMutableAttributedString alloc]initWithString:text]; [self.attributedLabel setText:mutableAttributedString afterInheritingLabelAttributesAndConfiguringWithBlock:nil];

Upvotes: -1

Sandeep
Sandeep

Reputation: 356

In my case, for some reason following code was causing the label to show only one row. Removing it helped ' self.attributedLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;'

Upvotes: 1

kohaXun
kohaXun

Reputation: 147

Strangely the problem solved itself. I could not figure out why this particular problem happened on iOS6 Simulator but now it works with NSLineBreakTailTruncation on iOS6 Device and Simulator.

Thank you for your responses!

Upvotes: 0

dominik
dominik

Reputation: 1339

I currently faced the same problem. Try setting the LineBreakMode before you actually set your text. E.g.:

TTTAttributedLabel* descriptionLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(20, 120, 280, expectedSize.height)];
descriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
descriptionLabel.numberOfLines = 0;
descriptionLabel.text = description;

Upvotes: 9

Jeepston
Jeepston

Reputation: 1359

Labels and textviews in iOS 6 support attributed text natively. So if you don't need to support older versions of iOS, you can get rid of 3rd party control.

Upvotes: 1

Related Questions