multiple line UILabel is truncating - objective-c

I want to display status on a UILabel. I want it to wraparound at word breaks if it's too long, and I want font size to shrink if not enough room in the UILabel.
UILabel is created in storyboard, and its Lines = 2, and Autoshrink is Minimum font Scale 0.5
But I can't make this happen. Text keeps truncating.

I got it working:
In storyboard:
1. stretched UILabel vertically bigger
2. Lines=0
3. Line Break = word Wrap
4. Autoshurink = Fixed Font Size

Related

UITableViewCell nib with several constraint scenarios

I have a UITableViewCell nib that depending on the data it can show an image or not.
Below, the cell has 2 labels and at the right most the imageView. What I want to do is to remove the imageView (if no image is present on the data) and extend the Label all the way to the right.
Is there a way to have several constraint scenarios on the nib that I could activate/ deactivate?
Constraints on label1
leading, 2. center vertically in container, 3. fixed width
Constraints on label2
Leading space with label1, 2. Center vertically in Container
Constraints on imageview
Trailing space, 2. Top space, 3. Bottom space,
Width constraint : width <= 50 (When there is no image then width will automatically get zero),
Horizontal space between
label2 and imageview = 0 (priority = 250)
See the below GIF:

Word wrap position in UILabel

When working with a muti-line UILabel object, is there a way to know at which position in the text the line wrapping will occur?
For example if the text of my label is 20 words, the display will be different according to the size of the box provided. I would like to know when (character position) the display is going to the next line.

How can i achieve Multiline UILabel with NSLineBreakByTruncatingMiddle and sizeToFit in autolayout?

I have a two line UILabel. I want its line break mode NSLineBreakByTruncatingMiddle. The problem i am getting is if text is small enough to fit in one line, its showing it in middle of label instead of at top. I am using iOS6 and autolayout so sizeToFit is not working for me.
How can i achieve this? I want if text is small to fit one line it should be vertically top aligned. I have tried this, but its truncating and showing the text in one line only rather than two line.
You need to calculate the required size and update the frame of your label:
CGSize s = [myLabelString sizeWithFont:...
constrainedToSize:CGSizeMake(..., MAXFLOAT)
lineBreakMode:NSLineBreakByTruncatingMiddle];
With whatever font your label is using and its width.

How to fix size of text in UITextField so it should not overlap the label?

I've a UITextField and a UILabel on it. The label is right aligned and the text is left aligned, the problem is that when i enter text in text field, whenever the size of text goes bigger it overlap the label.
How can i prevent the label to be overlapped?
Updated:-you can use table view cell of type value1 or value2 that gives you this format and Used TextLabel as main heading and place the textfield in place of detailtext.That can be fix.

How to do multiline UILabel in ios?

I'm dynamically populating the title (UILabel). Sometime it's bit too long and IOS squeeze the font to fit in the width. Is there a way to do multiline with using same font size?
Set adjustsFontSizeToFitWidth to NO and numberOfLines to 0.
numberOfLines Docs
This property controls the maximum number of lines to use in order to
fit the label’s text into its bounding rectangle. The default value
for this property is 1. To remove any maximum limit, and use as many
lines as needed, set the value of this property to 0.
If you constrain your text using this property, any text that does not
fit within the maximum number of lines and inside the bounding
rectangle of the label is truncated using the appropriate line break
mode.
When the receiver is resized using the sizeToFit method, resizing
takes into account the value stored in this property. For example, if
this property is set to 3, the sizeToFit method resizes the receiver
so that it is big enough to display three lines of text.
You may additionally want to specify the lineBreakMode unless the default UILineBreakModeWordWrap is suitable for what you want.
Use UILabel properties as below :
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.numberOfLines = 0;
Yes, you set the numberOfLines to 0, and the .lineBreakMode to UILineBreakModeWordWrap in code, or the equivalents if your label is defined in IB.
I just used LineBreak mode to Truncate Tail and setNumberOfLines to 0 and its working for me.
the label is of multiline now.