UITextView does not support any kind of tables, but I'm trying to create a text view implementation which would be able to show tables alongside normal text.
Basically: My macOS port uses NSTextTable to render some paragraphs next to each other when creating a PDF. I'm trying to come up with a way to achieve this on iOS.
Documentation and real-world implementations of TextKit 2 are still a bit hazy, but I'm interested if it would be possible to create my own content types using NSTextElement and NSTextElementProvider. If I'm reading it correctly, I'd define a range which is governed by my own implementation/layout?
As the documentation is so sparse, I'm very unsure how to actually implement an NSTextElement which would also be rendered as text when saved as a PDF — or if any of this would even be possible.
Any help or hints would be appreciated.
Related
I want to show a variable text on my universal iOS application. I load the texts from SQLite DB as NSString and almost each line of the text has separated atributes like Color. So I need to use AttributedText. Also I want to support both ios 7 and ios 7 and also in future iOS 8.
I noticed that there is two general ways: 1- Using UITextView 2- Using UIWebView.
I am wondering what is the advantages and disadvantages of using above features and witch of the is better for showing long length and very attributed text. And also is there any other solution for showing this texts.
The biggest advantage of using UIWebView is that you can render an HTML content through it -- any HTML content, since it is backed by WebKit.
On the other hand, UIWebView will add a noticeable delay from the moment when you add it as a subview to the moment when it will have finished to render the HTML.
You could also give a look at alternatives like RTLabel and others that you may find on GitHub. RTLabel is built on top of Core Text and supports HTML-like markup.
EDIT:
Some of them are about 40000 characters. It should be about 1000 paragraphs and each paragraph 1 line.
My suggestion is to go for some kind of paging to let the user move comfortably through all that text (40k chars would be like 25-30 book pages). This would improve UX and it would also make feasible the implementation through a UITextView -- performance-wise.
If you do not want paging and want just one scrolling view, then UIWebView could be better for your case since it should also do some kind of optimisation regarding portions of the page that are not displayed.
Finally, as a side node, since you specify that your text has a fixed structure (1000 40-chars lines), another option which you could consider is using a UITableView for this, provided that you can display each paragraph in a single cell row. This would be the most efficient solution since you have short pieces of text and the table view to handle their allocation/deallocation based on which ones (usually a small subset) are displaying.
I'm working on an iOS app in which I need to implement a basic text view with these requirements:
Rich text
Font emphasis (bold, italics).
Inline images for hyperlink-like actions.
Scrolling
Getting and setting the scroll offset (for remembering the previous scroll position).
Text selection
Getting the selected text character range.
Scrolling the view when selecting text, if needed.
I believe I could achieve this with UIWebView but the problem with this is that it provides very little control and is somewhat slow and shows a blank screen while loading. I was wondering if this could be achieved with Core Text but regarding the text selection I'm not sure. I'm hoping to achieve as iOS-native behaviour as possible.
What I'd need is pretty much like Instapaper's text view.
OmniGroup have done something like this by creating a text editor much like UITextView which draws the text using Core Text but also has all the editing features of UITextView as well as Rich text features from Core Text.
You can find it here.
There are some answers about this in StackOverflow, for example: Core text tutorial
However the best tutorial I ever read about Core Text in iOS is not listed in any answer I've found: How to create a simple magazine app with core text
Please notice that CoreText is only available for iOS 3.2 or superior.
I'm looking for ways to implement text selection over a parsed PDF in iOS. I already have the positions of all the glyphs by using the Quartz PDF parsing functions, but I don't know of a good way to implement the selection of the text without writing the selection logic and view from scratch (And display it either in the view displaying the pdf or in some transparent overlay view).
The experience should be similar to selecting text in a UITextField or UIWebView (for example).
Existing 3rd party solutions which I could integrate would be best.
Found the Omni framework, which implements a similar selection.
Working on an app that needs to take a large amount of text, paginate it based on user selected font size, etc., and display it with styles. Getting UIWebView to paginate a document has proven extremely troublesome. I have seen a wrapper for Core Text that apparently, takes care of layout, but my understanding is that core text cannot be selected.
Looking to do something similar to the books available through the app "eReader", or the app made for the book "The Adderall Diaries". Anyone know how they accomplished this? I had assumed it was UIWebView.
Normally I'd say using UILabel with NSAttributedString, however since you also need to select text, things get a bit more complicated. Head over to the Apple Dev Forums and check out the changes in iOS 6 to attributed strings (it's under NDA).
I'm currently scoping out a project for the iPad which is rather text and font heavy. There are many pages of styled text, which also need custom fonts. I have toyed with the idea of simply rendering PDF or PNG files on-screen, but I think we need to be able to dynamically repaginate the text.
We've used UIWebView in a previous project quite successfully, however there are a few things I don't like about it... Firstly, you have to hide all the silly drop shadow elements to stop them showing when the user scrolls beyond the bounds, and we had to add some JavaScript to find out actually when a page had fully loaded. Overall, the experience seemed a bit clunky, as well as worrying if the project could potentially break if Apple decided to update the subviews...
The other thing we've been looking at is Core Text, which looks very powerful. The only worry with this is that it appears to be a rather steep learning curve for us since we've mainly been working in UIKit (with a bit of Core Graphics). I couldn't even work out how to change the size of the font after a morning's work.
Are there any other alternatives*? Should I stick with Core Text? Is there any way of using UITextView with multiple fonts and styles?
Thanks!
:-Joe
EDIT: *by alternatives, I am really looking for built-in iPhone SDK alternatives only please... I would rather not mess with third party frameworks because I don't have the time... Thanks :)
You could use Pango, which uses CoreText when on iOS.