how to use paragraph text in uitableviewcell in cocoa-touch - iphone

I've been using uiLabels to put text in the cells of tableviews. I want to now use paragraph text that carriage returns to the next line instead of going out of the boundaries of the table cell. Would I do this by manipulating a uiLabel or would I use a different control all together like a text view.
Also is there any project examples out there that implement this?
Thanks,
Joe

Simplest way is to use a UILabel and set the number of lines in IB to > 1 then set the line break to "Word Wrap."
Another way is to use a UITextView, load the data and set it to 'disabled' so it can't be edited.
Finally, you can always go the UIWebView route and load it with formatted HTML, complete with line breaks, etc. Pretty heavy, but most flexible.

The simplest approach is to use a UILabel, probably. The only alternative would be to make a custom UIView subclass that draws the text directly, but that will give you marginal benefit.

Related

text-align-last css property Swift Equivalent

What is the swift Equivalent for 'text-align-last' css property?
I prefer a codeless solution.
Here is what i have done and what i get:
The last line (sometimes the only one) is aligned to the left, which is inconvenient.
You need to change the label's text from Plain to Attributed, then you can paste any string and the alignment, as well as other attributes, will hold.
So basically any text style that can create on word processor application can be used here.
In the following example I've used pages (Mac application) to edit the text format as I liked and copied it to the label text box in Xcode.
Here is a picture of the simulator running the app:
While it is not possible to apply different aligns on a single label, if the last(and sometime only) line should be aligned to the right why not align the entire label to the right?
EDIT
If that doesn't fix you problem then I don't think it's possible to resolve without code.
In the case you do decide to write some code you could look into determining which is the last line of your string (maybe: How to get text from nth line of UILabel? ) and try to apply different formatting with AttributedString.
If that works then you can always subclass UILabel and override func layoutSubviews() to calculate this automatically for you. This way you won't have to think about it again!

Watch App - Replace ... when text is too long

I have a problem with the size of my text.
When my text is too long in a WKInterfaceLabel, no problem, I just add line or I pass line at 0 to increase automatically the number of lines.
But with WKInterfacePicker, impossible to increase the number of line and I have "..." at the end of my text.
Do you have solutions to display all my text or, at least, to delete this "..." and replace it by some letters more from my text. I work with Swift.
For the second solution, I prefer have "My text" than "My te..."
Sadly, this is not possible. Apple doesn't provide any sort of way on managing that.
A possible, but rather complicated solution would be making a costume picker with labels with multiple lines and using the newly implemented WKCrownSequencer as well as the WKCrownDelegate in watchOS 3 to detect the state of the digital crown. The default picker animations might be impossible or very difficult to reproduce, but it might fix your problem.
try this set in size width = size to fit width content

jupyter - how to comment out cells?

Is it possible to comment out whole cells in jupyter?
I need it for this case:
I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)
Thanks
Mark the content of the cell and press Ctrl+ /. It will comment out all lines in that cell. Repeat the same steps to uncomment the lines of your cell.
I think the easiest thing will be to change the cell type to 'Markdown' with M when you don't want to run it and change back to 'Code' with Y when you do. In a short test I did, I did not lose my formatting when switching back and forth.
I don't think you can select multiple cells at once.
If you switch the cell to 'raw NBConvert' the code retains its formatting, while all text remains in a single font (important if you have any commented sections), so it remains readable. 'Markdown' will interpret the commented sections as headers and change the size and colour accordingly, making the cell rather messy.
On a side note I use this to interrupt the process if I want to stop it - it seems much more effective than 'Kernel --> Interrupt'.
You can switch the cell from 'Code to 'Raw NBConvert'

How to format different characters in a UILabel's string differently?

I have a UILabel with a dynamic string as the text property. If I always want the first word to be underlined, do I need to separate labels and then try to line them up correctly? Or could I subclass UILabel to have it do this?
Use a UIWebView and render the text as HTML.
I ended up using the textRectForBounds:limitedToNumberOfLines: to find the dynamic start point of the word (minus some x coordinate pixels), and then took away the first letter of the uilabel with stringByReplacingCharactersInRange:withString:, and then added another uilabel with the beginning letter of the original label, just with different font.

How to display multi-line text without scroll in UIView?

I have multi-line non-HTML text (with newlines). Need to output it inside ScrollView or just UIView.
I can't output it as UITextView: can't find how to resize UITextView to the size of text and/or disable scroll in it.
Should I output text to Label?
Or there's something more proper for that?
Thanks.
Try using a UILabel, then set the lineBreakMode property to UILineBreakModeWordWrap, and the numberOfLines property to zero (unlimited lines).
Depending on the style of text you're using, you might try stripping out the newlines so the result looks better.