I\'ve got a view that contains only a UILabel. This label contains multiline text. The parent has a variable width that can be resized with a pan gesture. My problem is t
In Xcode 6.1 for iOS 7/8, I was able to get this to work by just setting preferredMaxLayoutWidth
in a setter method that's called on my view to display the text for the label. I'm guessing it was set to 0
to begin with. Example below, where self.teachPieceLabel
is the label. The label is wired up with constraints alongside other labels in a view in Interface Builder.
- (void)setTeachPieceText:(NSString *)teachPieceText {
self.teachPieceLabel.text = teachPieceText;
[self.teachPieceLabel setPreferredMaxLayoutWidth:[self.teachPieceLabel bounds].size.width];
}