Displaying large PDF document iPhone - iphone

After many hours of googling I thought I would see if anyone knew the answer.
I have a large PDF file (30mb) which I was using the UIWebView to display but it is painfully slow when trying to scroll through pages and when you rotate the iPhone/iPad it doesn't draw properly on the screen till you have scrolled through a few pages.
So I have been looking into using the CGPDFDocumentRef to display the PDF. Before I go any further is there an easier way to do this, or any examples/open source solutions to do this before I spend a long time trying to replicate the UIWebView or something similar to display a large PDF.
I assume someone else has had this problem?
Many thanks for any help

I've been building one of these for a while now. I'll tell you, both approaches have difficulties. The CGPDFDocumentRef path is the one that I've taken, and it's worked out pretty well.
A good place to start is here, with Apple's example, ZoomingPDFViewer. You'll get a good idea of how that CGPDF* stuff works. If you're looking to put something together in a hurry, you might want to start with this guy's example. In fact, the author's website has a huge list of resources to use when you run into problems.

Related

PDF Reader like iBooks

I want to create a PDF reader like iBooks. So that you can see the thumbnails for the pages, press on it and it opens the page etcetera. Also the bookshelf for showing the loaded PDF's
Does anyone know how I can create something like that? Is there a library or does somebody knows a good tutorial?
Thanks in advance!
What I need is something like this:
For the page curl, see this discussion. For everything else, you should break the problem down into more focused questions since it's hard to tell how much detail to give (ie, we don't know how much you already know).
Update
For the drawing part, start with the Cocoa Drawing Guide and the Views Programming Guide. I believe you can get basic PDF thumbnails using the UIImage class.
This opensource project is the exact copy of the iBook pdf reader:
http://www.vfr.org/

Is there a View Controller to show thumbnails like the Photos app?

I am looking to replicate the image gallery view that shows thumbnails, like in the photos app on the iPhone.
Is there a view controller or any examples that anyone can provide to replicate this?
There isn't one provided by Apple. I would recommend looking at Three20. It has a few things with look a lot like the Photos app.
Another option is AQGridView.
Take a look at the video of Session 104 from the WWDC 2010. It's basically a 40 minute tutorial on how to do the photo app.
Bear in mind that allowing users to zoom will greatly increase the space required. If you use CATiledLayers, that is, which, depending on your desired zoom level, you should consider doing.
Oh, and there is source code ;)
What they don't tell you is how they did their tiling. I found that you can
a) download ready-made tiles from the server with the app or with a content update (you can use ImageMagick's crop tileWidthXtileHeight - e.g. crop 100x100 - to do the tiling). This has the disadvantage of large downloads.
b) download ready-made tiles from the server as needed (may lead to lags in your app, but then MKMapView does it quite nicely, doesn't it?)
c) tile on the phone as needed (here you can also consider caching the results, although that will likely mean you have to check space left on the device)
I've recently given enormego's PhotoViewer a try. It's easy to use, and it's much more focused than the Three20 project. (Which I also use and like a lot.)

Text Editor like Pages iPad App

I want to implement a functionality similar to found in Pages app..i.e. text floating around images, image zooming etc.. I have been struggling with this part of my application but no success yet. Would be grateful if someone provides me with some pointers in this regard , like 'Which UIControl should I use?','Help in thinking logic' etc..
Thanx in advance.
Sounds like a fun app to develop.
Some Pointers:
Immediately off the bat, I would say look into creating your own Controls for the floating objects.
I would suggest tackling a smaller project, or maybe a few small to medium size projects. p
Try making a few apps with WinForms or WPF. Also look into XSL:FO.
Immediately off the bat, I would say look into creating your own Controls.
There was a WWDC session that talked about iOS text. I don't think it's violating NDA to say this is going to be a very hard project. No, make that very, very, very hard.
You will probably need to do all UI yourself, and use Core Text for rendering of the text. (But I believe you need to draw selection, etc.) And do the layout yourself.

How would you design a question/answer view (iPhone SDK)

I'm new to iPhone development, and I have a question on how to create a view for my application.
The view should display a problem (using formatted/syntax highlighted text), and multiple possible answers. The user should be able to click on an answer to validate it.
Currently, I am trying to use a UITableView embedding UIWebView as contentView. That allows me to display formatted text easily.
The problem is that it is a real pain to compute and adjust the height of the cells. I have to preload the webview, call sizeToFit, get its height, and update the cell accordingly. This process should be done for the problem and the answers (as they are HTML formatted text too).
It's such a pain that I am planning to switch to something else. I thought using only a big UIWebView and design everything in HTML. But I looked at some articles describing how to communicate between the HTML page and the ObjectiveC code. This seems to involve some awful tricks too...
So... that's it, I don't really know what I should do.
I guess some of you dealt with such things before, and would provide some greatly appreciated tips :)
The catch here is that the iPhone API does not yet support NSAttributedString so you can't just set the text to appear as you would like in a textview.
I saw one work around which essentially used individual UILabels to represent each attribute run. (Can't find the link now.) They used NSString UIKit extensions to calculate the position of the strings on the view and then used that to position the labels.
Another work around would be to draw the strings with their attributes to a UIImage and then just display the image. That would be the easiest solution I think.
In either case your going to have to basically recreate the data structure of an attributed string.
NSAttributedString does a lot of work for us. We really miss it when it is gone.

Replace UINavigation with UIToolbar?

I've built a Navigation-based app, but now that I'm knee-deep in the code, I've decided it would actually be best to have just a UIToolbar instead (only need modal views, not drill-downs). But extricating the Navigation stuff and replacing it with a Toolbar is causing me all sorts of grief...
Has anyone ever done this, and maybe has a pointer or two? Or even know of a walkthrough linked somewhere?
Thanks!
Bite the bullet and rewrite. Any guides out there will not be specific enough to your situation.
99 times out of a hundred if I realise I've made a massive design mistake and don't change it, I end up regretting it more than if I do. And since you'll take a copy/start from scratch again, you can always revert if you need to give up half way through!
Seriously, because this is a current app that is still (relatively) early in its development life and is all fresh in your mind it will very likely be quick to re-do. Also, sounds like this might be one of your first iPhone apps so you're likely learning new stuff every day - now you get to put all the new stuff in this app too. And finally, just imagine the work involved if you put another 200 hours into this as it is and then decided you had to rewrite!!
Hope that helps, and I bet you get it rewritten in less than a day!