I am trying to make a notification section using table view, view the cell is tapped then it will show the detail of the notification info like this
as we can see in the first picture (table view cell), the text (the text content, not the title) is clipped. I don't think this is an autolayout issue, since I have set the autolayout constraint like below
I hope that I can get the table view cell like below, some context will also be displayed in 2 lines in the label.
I suspect this is because it has entered text
Dear All,
(enter)
Perlu kami informasikan bahwa ..........
maybe thats why i get
Dear All, ......
could you please help me ? Thanks in advance
The entered text has embedded newline \n characters. That's why you only see the first "line" of the text, followed by the clipping ....
To fix that, replace the newline characters with spaces:
// example
let ls = "This is\nSome text"
let t = ls.replacingOccurrences(of: "\n", with: " ")
print("t", t)
// output is "This is Some text"
So, when you want to display the "abbreviated" text, replace the newline chars. When you "expand" the cell, you'll need to show the original string.
Related
I often have lots of data in spreadsheet cells but I don't necessarily want all the text to show in the cell as long as I can edit it in the formula bar.
So, for instance, I'd like to have the text "this text is a long sentence" in a cell but only display "this text is..." but if I click on the cell, the whole content displays in the formula bar so I can edit it.
I know that this relies on custom display formats but I can't find a way of making this work. There doesn't seem to be a placeholder for a single character, only the whole string (#).
EDIT
This is a link to the sheet ...
https://docs.google.com/spreadsheets/d/1Ahi1CsGAiD02tvAmKuQAKnNemyYdh6AUb1GcrwZCubI/edit#gid=2014979721
... this is a mock up of what I'd like to see in the cell.
Can anyone help?
I'm trying to create an expandable label that looks like the one in the picture:
I have two problems:
How do I make the label truncate the tail such that it leaves enough place for the More button/clickable text?
How do I place the More text?
Maybe, I am going about it the wrong way? Instead of playing with the number of lines, should I maybe try to calculate how much text goes into one and a half line and present it only, and then when clicking More I present the whole text?
Would appreciate any advice, thanks!
You can use this library to achieve your expected output.
https://github.com/apploft/ExpandableLabel
Specify the number of lines you want to display default.
expandableLabel.numberOfLines = 2
Set true if the label should be collapsed or false for expanded.
expandableLabel.collapsed = true
collapsedAttributedLink
Set the link name that is shown when collapsed.
expandableLabel.collapsedAttributedLink = NSAttributedString(string: "More")
expandedAttributedLink
Set the link name that is shown when expanded. It is optional and can be nil.
expandableLabel.expandedAttributedLink = NSAttributedString(string: "Less")
I have a cell with the following, some text|, some text|, some text| and I want it to appear as follows in another cell.
some text
some text
some text
I'd like the text to display in a single cell, but with a blank line between each (some text) at the "|" (pipe) character.
I've tried the this, =SUBSTITUTE(D31,"|","&CHAR(10)&CHAR(10)&"), but it puts the &CHAR(10)&CHAR(10)& as part of the string.
Any ideas or solutions are greatly appreciated!
=substitute(D31,"|,",char(10)&char(10))
Details of the issue :
When display text inside UILabel and almost the text fill complete line, if you add one more character with spacial character such as "ً" (check number 1) , it cuts first letter of text and put it in line alone(check number 2) and the rest of text in other line (check number 3)
Please note that the issue happening in the Facebook app and iOS note app
Try setting the linebreak mode to word wrap.
This may help.
Another option, try using textview instead of label.
I have a uiTextField with dynamic text.
How can I set it via the editor to split the text into 2 lines (or more)
if text doesn't fit in the uiTextField width?
Is there a way to do this not programmatically?
Now text is seen as
"This is a long line" ===>
"This is...."
and I want it to be
"This is a
long line"
UITextField is one line only. You can not have multi line content in UITextField. If you want to have multi line then use UITextView.
As Vishnu said you need to use UITextview for multiple row textfield
also add a "\n" where you want to break the string into the next line like so
"This is a\nlong line"