iOS cannot select/highlight text in PDF - ios

I cannot select/highlight text in my PDF reader (when you press and hold text). I used the following to open/read PDF documents
http://developer.apple.com/library/ios/#samplecode/ZoomingPDFViewer/Listings/Classes_PDFScrollView_m.html#//apple_ref/doc/uid/DTS40010281-Classes_PDFScrollView_m-DontLinkElementID_4

Actually, with iOS5, Apple added support for text selection in UIWebView.
Unfortunately, there's no API for this, and their support is rather clunky and slow. And embedding UIWebView's into your app is a rather ugly solution. (and you can hardly control the UI)
You might wanna check out 3rd party iOS frameworks for that feature. https://stackoverflow.com/questions/3801358/pdf-parsing-library-for-ios
I worked the better part of year to roll my own PDF parser that calculates the glyphs to get text selection. (it's commercial, google for PSPDFKit)

Related

How to use Swift Playgrounds-style code input keyboard/text field in normal text view?

I'm making an iPad app that lets me write swift code into a text box and save it to a document. It doesn't do any compilation or any complicated stuff like that, so I'm just looking for a way to format the code correctly in the text box (ex: code autocomplete, autoindent if possible, and maybe syntax highlighting). In short, I'd like my app's text field and keyboard to look similar to those of Swift Playgrounds.
If Apple's provided the code (or a built-in keyboard option that can do even some of this), I'd appreciate a link to it. Otherwise, how would I go about building a custom keyboard and text field (or at least disable the features like autocomplete that would get in the way)?
Thanks.
As far as I know the only way to do what you describe is to build a Swift Playgrounds app that presents a code editor window. Apple does provide documentation on creating third party iPad Swift playgrounds. I suggest looking it up on Apple's site.

How to highlight text in a textView in Swift?

I would like to highlight a part of text in a UITextView like Pages for iOS or Safari for iOS do. I search the documentation but I can't find a way to do it, maybe because I'm a beginner in iOS development and I miss some crucial info. Somebody can help me?
Screenshot of Pages for iOS:
Screenshot of Safari for iOS:
If you only need to highlight a single, contiguous block of text you can set the selection programmatically. Your examples show multiple discontinuous parts however. For that you are going to need to use an attributed string. There is no other system-provided highlighting function. (There might be a third party library that offers this though - you'll have to search.)

UItextview vs UIWebView for showing long attributed text in the iOS

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.

PDF text selection on iOS

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.

Is there an alternative to UIWebView for dynamically displaying formatted text?

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).

Resources