I have about twenty UITextViews and corresponding .txt files. What I want is to make each UITextView take the contents of the corresponding file and display it.
Moreover, the text is formatted and it contains some formulas (copy/pasted from Grapher). I've heard about displaying formatted text in UIWebView, but I haven't found a clear explanation anywhere.
Thanks in advance!
Text files normally don't contain formatted text.
If by "formatted" you mean "html" then yes, you will want to use UIWebView. Basically you will convert the text to an HTML document, and then use the web view to display that document. There are several example projects available from Apple that show you how to use UIWebView.
Displaying formula in a UITextView will be difficult as the character rules for formula are completely different from language text. You could generate HTML to display it that but that is difficult as well.
I think your best bet would be to draw the formula to an image and then display the image. That is the traditional way to handle the display of formula.
Related
I am trying to create a program that displays pdfs in chunks. So if you have a 100 page pdf and you only want to display the first chapter you could code something for only showing pages 1 - 10. I've searched around and as it stands it seems this is the best way to display pdfs. The problem is this loads the entire pdf at once in a reader. Going through the documentation now and I can't find anyway to selectively display the pdf. is there a way to selectively display pdf text using pdfkit? or will I have to use some other library for that?
I also see there's a tabViewStyle(.page) I can use to get a paged reader view in swiftui but I'd prefer not to have to format and prettify the text if possible.
I'm not opposed to using 3rd party libraries I just don't want to have to deal with formatting text or whatever. thanks!
I have a list that I want to display some text as bold and other parts not bold. First of all I have been accomplishing this when not inside of a list by just making a bunch of labels and then manually going through the text adding \n and spaces for formatting, which takes forever. If there is an easier way of doing that I would love to know. Anyway my question is how can I add formatted text to a list.
So instead of those individual text elements I want to add multiple formatted text elements in place of one.
how can I add formatted text to a list
sorry, that's unfortunately not possible with App Inventor
you can take a look at this App Inventor Classic example, which uses some HTML to do the formatting
I hope this is a really simple question, but it's stumped me. Basically, I have a huge amount of text that I'm using the text view for. For the most part, it's just the system font. However, I would like to format "headers" every few paragraphs in the large chunk of text with a custom font (that I've added to my project) and background color. How do I target small pieces of text within the text view?
If it were just a small piece of text, I would just add a label and do it with code, but since this a huge piece of text, what's the best way to do it?
Thanks!
If you load a large amount of static text with formatting, I suggest you save it as a html file and load it into UIWebView.
Can anybody tell me if it is necessary to select the text in a PDF file loaded within a UIWebView, or is it selected on its own?
If it's not selected, how can we implement the selection of text within such a PDF?
The UIWebView actually draws the PDF pages as images so you don't have access to individual items (textfields, images etc.)
Highlighting isn't by far a trivial task. One solution would be to use the CGPDFScanner to parse the page's stream and figure out how to concatenate the transformations for the text operators (TJ, Tj, Tm, Tc, Tw etc.) in order to get the individual glyph positions. If you succeed in doing that the rest should be pretty straight forward.
im having problems with formatting for a UITextView. my app pulls in XML, saves some of it to a string , and then displays the text in a UITextView.
it understands if you put a return in there, and it starts a new line. but i want to put paragraphs in there, any idea how i can pass that information without doing multiple UITextViews
Thanks :)
If you are converting to text from XML content, then it is probably easier to use a UIWebView and format using html.
If you want total control of formatting, then you need to move to using Core Text (3.2/iPad).