iOS gradual swipe between pages on a PDF/ePub reader - iphone

I have a swipe gesture that changes the pages between ePub/PDF pages instantly. It uses a UIWebView to display the pages and [_webview loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:_pagesPath]]] to change the page. I have no where to begin to implement it so that it will gradually swipe between pages instead of instant.
Are there any tutorials anywhere? Or if someone could explain the basic theory / which view controllers to use etc?
I'd be very grateful.
Side note:
I'm very new (as in I started learning obective-c a couple of days ago) to iOS development. I have a very strong background in OO PHP and client side web technologies.
I downloaded a pretty good ePub reader app and have stripped it down and rebuilt it to understand how it works and to teach myself objective-c quicker. So far so good, just made some changes so it'll accept PDFs as well and put in the swipe gestures.
Regards,
Kieran

You really shouldn't use UIWebView for pf rendering - it's slow and not really customizable. Apple has introduced QuickLook in iOS4 as a better alternative, but it's also quite slow and static. If you need something fast, you hace to do it yourself, with Quartz and the CGPDF* API.
For the swipe gesture, what you want is a UIScrollView with paging enabled, that's much better than static sliding and lets you drag the pages fluidly. You also may need to reuse the views inside the UIScrollView for better performance.

Related

Xcode: Pdf's in a UIScrollView with Paging enabled

Im having trouble loading pdf's in a UIWebView when inside a Scrollview with paging enabled and just can't get my head around it.
So i started with the paging sample code available at apple developer, once done that i loaded instead of a Label in the ViewController a UIWebView that loads the Pdf. and it did worked but with a lot of bugs with rotation and scaling on the device.
On iOS 5 scaling is simply not working it zooms but scrolls to top and doesn't allow me to move inside the UIWebView so when I move the only thing i do is move between the pages not inside the UIWebView.
And with iOS 4 it does let me move but has tons of trouble when rotating the device, it doesn't refresh the UIWebView inside to the new frame (even though i do change the frame on didRotate method), so i was wondering if there is another method to load the PDFs that is not a UIWebView that is compatible with zooming and rotating with the UIScrollView with Paging.
Or is there something I should consider when loading the UIWebView inside the UIScrollView? a feature i have to enable or something i am missing?
Because at the beginning I thought it was a bug on iOS 5 and that i was doing something wrong when rotating (which probably i am anyway) but i have several apps on my iPad with ios 5 that do the same but have absolutely no trouble.
I hope you can point me in the right direction.
Thanks in advance!
You should really be using CATiledLayer and CGPDFDocument for this kind of stuff.
There is an example that I found just now : Olive Toast's Blog
Its time consuming to wrap your head around these concepts, but its well worth it. I created a webView+scrollview combo for a pdf reader, which had to be junked and rewritten with CATiledLayer.
Doing it using webview in scrollview gobbles up a lot of resources, ending in a very bad UX
Edit: Apparently there is another post that has a better answer than mine (you may find this link useful)

UIScrollView performance issues

I am bundling up 2000 - 5000 images in uiscrollview with names. The current scrollview has quite hiccups during scrolling.
So the question is about how to improve performance. What I have searched so far is that I would have to get on NSOperations, NSQueue like things. But I'm not able to get any code sample on that. I remembered watching some video on WWDC 2010 on boosting performance of UItableview loading images being exhibited. Unfortunately I'm not able to remember that title too (worst perhaps it was 2009 video session).
So please can anyone point to me in right direction about what tutorial or sample code should I see. Atleast apple ios library reference links?
UITableView uses lazy loading of reusable cells from a pool.
I'd advise you look at implementing something like this, so that only images objects that are actually viewed fetch an image.
NSOperations may be something you could look at to implement the actual fetch with but also consider using ASIHTTPRequest to asynchronously grab them as this handles all the queuing and threading for you.

Creating a tableview in the form of a 'film strip'

I am developing an RSS-reader-type application. I am toying with the possibility of using a normal TableView application but showing the articles as a film-strip. I am mainly thinking for an iPad application (but possible it works on the smaller iPhone as well).
The idea is to have the cells passing/scrolling across the screen using swipe touches (but horizontal, and not vertical as with the normal TableView). They will be some-kind of miniatures of the full article, and when tapped (or with multi-touch zoom to have better control) can be enlarged to read. Then can then just be be moved on as soon as the user has seen enough of it.
Does anybody know if there is an easy way of accomplishing something like that?
The most obvious solution that springs to mind would be to use a UIScrollView, as this will provide the inertial effects, etc. for free - all you'd have to do it populate it with the relevant sub-views. (UITableView's actually use a UIScrollView.)
For more information and sample code, see Apple's UIScrollView docs.
If you want horizontal scrolling, take a look at Jeremy Tregunna’s JScrollingRow. It’s open source under a public domain licence.

Bubble Chat + Emoticon + UITableViewCell

This is a question for iPhone development and I'm hopin someone can point me to the right direction on how i should go about implementing this.
I am trying to write a chat application that supports emoticons/smileys. Where the smiley/emoticon images are stored can be figured out later. I think few iphone applications out there are already doing this (i.e. skype + ebuddy(?)) but not sure what method they went for.
After searching around, there seems to be a few ways of doing this (i think):
bubble chat style which has been discussed before. UITableViewController with custom UITableViewCell. For emoticons, might have to do a whole bunch of calculations to determine where to stick a UIImageView for each emoticon.
Use UIWebView as the whole "window". Style it to look like bubble chat. Takes away any manual calculations on image smiley placements.
I have no idea what the performance is like for each of these two methods, how complex it can get etc, so any comments and guidance will help for sure. Cheers
If you use custom UITableViewCell, then I'd probably implement drawRect: instead of adding labels and images. One will probably take as long to implement as the other, but it will perform much better.
The UIWebView might be worth a short, although you will have to make sure that everything looks right there, too. Instead of using one big web page, I suggest simply throwing in a web view into each table view cell.
Personally I prefer the first approach, measuring and layout of text is not too complicated, but then I've never been the ultimate HTML guru.
I agree with #Eiko on making custom UITableViewCells, especially using drawRect instead of adding labels, images, etc.
If you used a UIWebView how would you handle updating it? A complete reload each time new text is sent? That seems like it will be a cause of issues. Once you get a long conversation reloading the entire UIWebView's contents will cause some flickering which isn't acceptable in my opinion. Also using a UIWebView would require you to have 2 complete copies of each conversation in memory. 1 as your backend data and 1 as the HTML. Where using a UITableView you have your backend data, and only enough of that will be duplicated that can fill 1 screen at a time.

Display "custom" view (various images, various text). Should I use UIWebView?

First: No, none of the content should be loaded from the web. All content parts are shipped with the main bundle.
I have n images and mass of text (including lists). Instead of building all view parts programmatically in objective-c if was thinking of using an UIWebView and build "only" the HTML dynamically.
Does anything speaks against it?
How does UIWebView work with local content?
Links and resources welcome.
Thanks
I would not recommend using the WebView for building application UIs. It introduces many elements that may cripple the user experience. Well, it basically depends on the complexity of the UI.
I created an App UI in WebView myself, using JavaScript and all that advanced CSS animations/transforms that WebKit has to offer, but in the end it was not good for the consumer. My goal was to make the app skinnable, but if something goes wrong - for example in JS - the WebView is stuck, except you spend the time into building a WebView wrapper for your app that deals with this.
That said I, i don't know how complex your UI is going to be, but I would say using IB or building the UI in code with cocoa is still more efficient.
Regards, Erik
I've thought about using web views in these situations sometimes, but then decided against it. 99% of the time, it's better to design the screen in Interface Builder. That will be as fast as or faster than creating an HTML page, and will give you all the benefits of elements functioning as expected (text input for example) and the possibility of customizing things programmatically. But of course, in many scenarios a web view might be the way to go (in fact, several standard UI elements have underlying web views).