I am new to iphone development.I have created three labels in a cell and i have just displayed the text in the corresponding labels , but i want to display the full text in the label.I am not able to see the full text,So is there any possibility for breaking the text and show them in two lines.I am not displaying any static text .I am getting the text dynamically from the website and displaying it in the label.Please help me out.Thanks.
set label's numberOfLines property to 2 (or to 0 to have any number of lines you need)
set label's lineBreakMode property (e.g. to UILineBreakModeWordWrap)
make sure that label's height is enough to contain 2 (or more) lines of text
Related
I have a UILabel which has 4 lines. Its font size is 15 & autoshrink is enabled. It's minimum font size is 10.
When my text is too long then it automatically starts from first line. But when my text is too small then it starts from middle line.
How can I make sure the text always starts from first line, whether it's too long or too short?
I think what you're looking for is more a UITextView than a UILabel.
From Apple's doc :
UITextView displays a region that can contain multiple lines of editable text.
The editable part is optional. You can disable it, along with scrolling if you want to be close to a UILabel.
I have taken a custom tableViewCell with 2 labels .if the text in the second label exceeds i am showing the text in the second label with middle truncation. when the user clicks on the truncated text cell i need to pop up an alert with the complete text . any idea how to find the cell which contains the truncated text .
a lable is truncuated when it's size become greater than fram width. you can find both these by using
lable.frame.size.width
and NSString sizeWithFont method. compare then and found if your size of lable is greater than width. enjoy :)
as you uses a custom tableviewcell just give your labels tag values and at the time of cell click just find out both the labels using the tag values and do what you need to do ie show whole text to user in alert view
What i Need to do for our project is to Display several UIScrollViews in a View and weithin the scrollView a Headline and a Short Text.
I Know how to add a Label to the UIscrollview, but how Gould i handle the Case that the Headline-Label is too Long and wraps to a Second Line.
You can determine the space needed for the headline text by calling -[NSString sizeWithFont:] or one of its variants. Then size and position the labels dynamically in your code (and set their numberOfLines property to 0).
Alternatives:
Use a UIWebView to display formatted text (HTML).
Use Core Graphics to draw the text directly into the view (e.g. [NSString drawAtPoint:withFont:]).
Use Core Text to format and draw the text (quite complicated).
I am having a problem with the UITableview cell cutting off strings whose characters are more than 12 chars. Any ideas why this would occur? I have not made a custom cell at all. I cannot find any solution to this problem through a Google search. Any ideas?
You should be able to set the label properties to re-size the font based on the label's contents using adjustsFontSizeToFitWidth. This will essentially decrease the font size to make the text fit all on one line.
Your cell likely contains a label, which in turn is set to given bounds. What you need to do is ensure that your label is the same size as your longest string, or bigger than it.
I want to have a tableview create rows that look like this:
value1 item1 container1
value10 item10 container10
value100 item100 container100
value2 item2 container2
What I am trying to show is that the first word (value) will have a set length of 12 and then the second word (item) will have a set length of 10 and then the last word (container) is just tagged on at the end.
I am pulling these from a SQLite database and don't want to use multiple lines, but read in a strictly formatted structure like this.
You can layout a custom UITableViewCell in Interface Builder, where you drag two UILabel views onto the Content View and set their size appropriately (Notice that the letters may vary in width, so even though you know it's 10 chars in length, you don't know the maximum width, please keep that in mind)
Then you just fill the open space at the right of a cell with another UILabel, layout it to cover the open space and set it to autoresize it's width and set the right margin to be fixed.
There are quite a few tutorials available on how to use the custom cell in your tableView, I can recommend you this screencast. It explains how you can initialize the custom cell and how you can access the custom labels.
It sounds like you want something like an old-fashion text display in which then nth character in row zero always lines up the nth character in every row.
Even using carefully positioned labels in a custom tableviewcell, you will have to strictly control the specific font and its size if you want all the characters to line up in fixed width column. You will need a fixed width font to begin with and you will have to set the size precisely.
You might want to consider whether this is necessary. iPhone users are used to propionate width text displays. Very precise columns of text might make it difficult to discern rows. I would test first with just a simple table before spending the time tweaking the columns.