Is it possible to add a vertical line beside a paragraph with UITextView/UILabel? - ios

I'm looking to build a UITextView/UILabel that allows for quotes to be distinguished visually. The most common way to do this is seemingly a vertical line to the left of the quoted portion.
An example would be [this article] from Daring Fireball, notice the line by the quoted portion:
How would I go about accomplishing this with UITextView/UILabel? I can figure it out in UIWebView using CSS, but unfortunately UIWebView simply won't work in this project (due to these quotes being in numerous UITableViewCells). Similarly manually indenting paragraphs wouldn't work as it could appear anywhere in a block of text, perhaps the third paragraph, so I wouldn't necessarily know where to put it.

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 copying multi-row text from Google Sheets to the Instagram caption box add a quote mark at the beginning and end of the text?

This may be the most niche question ever but let's try it anyway.
I have a Google Sheets spreadsheet that contains cells with multiple lines of text. Each line of text is separated by a soft break.
As shown below, when I copy the contents of a cell (row 2 in the screenshot) from the Google Sheets app to the Instagram caption box, a quote mark is added to the beginning and end of the caption.
If I copy the contents of a cell and that cell has only a single line of text (row 3 in the screenshot), no quote mark is added.
I am using an iPhone 11 running the latest version of iOS.
The extra quotes are added when there are special characters in the cell. In your scenario, the Line Feed characters are causing this. Definitely annoying.
There is a way around this – using Carriage Return characters, rather than Line Feeds to separate each line. For some reason these characters don’t cause the quotation marks to appear.
One thing you can do in your sheet is to create a helper cell that will take your text, and replace the line feeds with carriage returns (assuming your input text is in cell A2, add this formula to an empty cell):
=SUBSTITUTE(A2,char(10),char(13))
The output for this will look like it doesn’t contain linefeeds, but when you copy & paste from that cell, the linefeeds will be there in the pasted text, without the extra quotation marks.
The quotations are inserted by the target application when non-printable or otherwise incompatible characters appear in the copied text. There are several scenarios in which the quotes don't appear, and several in which they do.
For example in the MacOS Notes application, consider a cell containing either a vertical tab (appearing as a line break in a single cell with a Cmd-Enter on Mac or Cntl-Enter on Windows) or a newline character in a formula such as ="test"&char(10)&"test". When copied and pasted into a record in Notes, the text is copied as is (i.e., as expected). However when pasting into the Notes search box, the quotes appear, such as described in the question.
There appear to be 3 alternative ways to handle this issue:
Strip the non-printable characters with a formula
Using the CLEAN function, the characters will be stripped. This will produce oft undesirable results, but will eliminate the quotes. See the Wrapped in CLEAN column:
Paste elsewhere first
In the Notes example, one can paste the offending text into a Note (or presumably any text editor.) The offending quotes are omitted. The text can then be recopied and repasted without quotes. This will still collapse a line feed into a space:
Publish to Web and copy from there
Publishing a sheet with non-printable characters enables quoteless copy, like the previous option, but may be a preferable. See the test sheet
Copy from the Sample Text column. You can paste without quotes, but the line break is stripped and replaced with a space as above.
this is a common issue. the solution would be to paste your copy into fx bar instead of cell selection. this way you can skip the additional quotes
The easiest of the easiest solution is to copy straight from the cell. Mark the text within the cell instead of marking the whole cell and then copy.
its very easy guys
just follow as i say
step1: type letter in a cell
step2: select logo(A) with 4 dash(-) which is on top
step3: select cell
step4:turn on wrap text
problem solved
if you are using desktop
mac: alt/opttion+enter
windows: alt+enter
you can also select all cell at once then you can select format on menu bar and select text warping and then wrap(this is not recommended as it may destroy your table format)

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.

UIWebView locating text by touch

Would like to capture a touch on a UIWebView, map that to the relevant HTML text and insert a hyperlink into the HTML at that point.
Found a very nice reference to cleanly capture touches on UIWebView at:
http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way/
I've implemented it and it works very well.
Also found a very nice reference to search and highlight text in a UIWebView at:
http://www.icab.de/blog/2010/01/12/search-and-highlight-text-in-uiwebview/
I've implemented it [for a search feature] and it works very well.
But I can't quite make the intellectual jump from touch position [not text search] to a specific word in the UIWebView. Obviously this can be done, since touch-and-hold on a UIWebView triggers a "Copy or Define" popup which obviously knows the specific word you've pointed at.
The individual text nodes that JavaScript decodes from the DOM have no offsetLeft or offsetTop or offsetWidth or offsetHeight; I understand these need to be derived from the parent node.
But the individual text nodes can consist of many lines of text, depending on what the HTML source looks like. Potentially a single text node can contain an entire paragraph of text, hardly the one word that I'm trying to spot.
Can anyone suggest how "Copy or Define" can be so clever? Thanks.

sifr 3 - at my wits' end trying to get the text blocks not to wrap

Looking forward to any help/comments on any aspect of this, but the main question is about sIFR text wrapping, and how to disallow it. This was supposed to be a simple html-izing job (ha ha ha)
Check out here
So I've housed the nav and the content clip boxes in tables, which I know you purists might disdain, but it seemed the easiest/most consistent way... please forgive.
The problem is the sIFR - I can't get one of the nav items ("Exchange Technologies") to behave; it keeps wrapping. Meanwhile, the sIFR headlines in the little content boxes have become unruly and are trying to escape.
I've clogged up the CSS trying to fix it in various elements -- I would be so eternally grateful if a sIFR expert would check it out and see if there are any suggestions on making the sIFR heads work.
Note that I do not need any padding on the bottom of the sIFR elements because the headlines are rendered in all caps.
If it would help I could send along the image of what the designer was looking for.
The forceSingleLine parameter for sIFR.replace() is the easiest way to resolve this. The problem usually arises when the Flash text is wider than the HTML text, and the elements being replaced are exactly the width of the HTML text. In this case the sIFR text won't fit in the allowed space without wrapping.
Another solution is to use letter-spacing through .sIFR-active .myNavItemToBeReplaced CSS rules, to make the HTML text wider so the Flash text does fit without wrapping.

Resources