ReadMoreTextview not working on New Line of text - ios

I'm using see more & see less functionality using this code. But I'm stuck on one condition that is if I've content with \n or new line text then it's not working as I expected.
If I tap see less off text then it's expanding to full text. But not in exact See Less text.

Related

NSTextView - using up/down arrows moves paragraphs not lines

I have an app that runs on iOS and uses UITextView to display rich text, and also runs on Mac and uses NSTextView to display rich text. These are separate apps, but with a lot of shared code. In both cases, the {NS,UI}Textview is programmatically created and placed on a canvas.
{NS,UI}TextView will wrap long lines of text as required. Long lines are called paragraphs and have NSParagraphStyles that can be applied across the whole paragraph (line spacing, head indent etc). Each paragraph is delineated by a "\n" character (or one of the Unicode equivalents). Paragraphs wrap across multiple lines, if required.
On iOS, when you have a long paragraph covering multiple lines... if you use the down/up arrow keys, the cursor moves up and down by lines (i.e. possibly within the same paragraph), which is as you expect.
On the Mac, with the same setup, the up/down arrow keys move the cursor up and down by paragraphs (i.e. multiple lines), which is very much not what you expect.
I have attached videos of the two cursor movements so you can see what happens.
I use the same code to create the {NS,UI}TextView, and I can't see why there is a difference.
Does anyone know what's going on here? I have not interfered with the arrow key handlers in any way (although I do implement textViewDidChangeSelection: in the delegate, and can confirm that the selection is changing per my comments above).
Any ideas would be most appreciated!
Thx.
iOS Cursor Down in a UITextView.
Mac Cursor Down in an NSTextView.
Found it! It was an errant calculation in the delegate function DoCommandBySelector.

Why does pasting(ctrl-v) sometimes break merged cells in google sheets

I am creating a PO form for my department. I have 2 cells merged with text wrap for the item description. If I copy a product name from Amazon and paste it into these merged cells, the merge breaks and text does not wrap. If I take the same text and paste into google search bar and then recopy the text and paste into the merged cells everything functions as normal. It does not appear to be the length of text but rather the font size that is the issue. Paste special- values only also fixes the problem but I am trying to make this form usable without special instructions. Does anyone have a work around or at least confirm font size can break a cell merge?
Font size is not relevant. You're copying a special character (likely a newline) at the end of the product name, which causes the merged cells to split.
There isn't anything you can do on your side to fix this, copy pasting formatted text directly from a webpage into your sheet will lead to things breaking.
A few options:
Double click on the merged cell, then paste the text into it
Select the merged cell and paste the values into the formula bar
Paste Special - Values
Answer:
I can confirm this does happen.
Workaround:
Instead of merging cells like this:
You can just use one cell and expand its width:
Fixing Font Size:
The only issue here is that if you paste in some text which is font size 18 and Times New Roman, if you don't use the Right Click > Paste Special > Paste values only then the text decoration will persist. You can fix this with a little script which changes the font to normal on edit:
function onEdit(e) {
e.range.setFontSize(10)
.setFontWeight("normal")
.setFontFamily("Arial")
.setFontColor("black")
}
This you will need to paste into the script editor for your sheet, by following the Tools > Script editor menu item. Once pasted, you will need to save the script with Ctrl+S. Anything pasted will now automatically be converted to Arial, size 10, black, normal weight font:

UILabel word wrapping brings extra word to next line when there is enough space for it

Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.

UILabel text wrong new line when has special character

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.

Multiline label with different font styles and IBActions

A perfect example of what I am trying to do is the Instagram comments.
Suppose we have a user and a list of text (the comment). I want my UIView to have the username in some font style and clickable along with text next to it and wrapping around to the next line (which is not clickable).
It might be easier to understand if you just look at this:
Notice how the username is clickable and separated from the text, but the text wraps around to the next line. How can I do this?

Resources