Xcode: Pdf's in a UIScrollView with Paging enabled - iphone

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)

Related

Huge image I want to manipulate in my Xcode app

I have a huge map image (25mb) that I want to use in my app. The entire point of the app is to pinch zoom and scroll around this richly detailed map.
I am loading it in a uiimageview, with some subview layers that can be toggled on and off to overlay the map.
Everything is working fine code wise and on my simulator, but my concern is that the actual iPhone/iPad may have problems rendering/manipulating a 25mb png image.
Anyone have experience with huge image files in Xcode? Any recommendations or concerns about what I have described?
Someone suggested using uiwebview to display the image. I'm not sure why thy would be any better.
Thanks
Best way to handle very large images is to chop them into easily manageable square chunks and load them dynamically. Here you can see a very nice tutorial for a tiled UIScrollView. Modding the code a bit will surely suit your needs.
Check out the ADC Videos, specifically WWDC 2010 Session 104 "Designing Apps With Scroll Views". This shows how to use CATiledLayer.

iOS gradual swipe between pages on a PDF/ePub reader

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.

three20 TTTabBar performance?

I used TTTabBar in the Three20 library. It seems to be a good simulator. But its scroll speed is significantly slower in the device (iPhone 4).
All I did was just replacing few names in it. So I was curious if maybe I did something wrong. So I tried the sample project provided by the library. And it's slow too!
How to use it not slowly?
I think the TTTabBar is used in the 'USA TODAY' app. It almost looks the same, but it's not slow. There must be a way.
It can also depend on the content which you are going to load (meaning web content), images from the web service in to the scrollview.
Or maybe you have provided the animation to the component within the scrollview. Check it out.
If it is animation then give minimum animation time as the device can not respond fast to touch or gesture as in the simulator.
Is three20 Library free of cost? I have one for a PDF book to turn the pages like with gesture (how can we know that particular library is free of cost?).
Try to load all your content in the initWithNibName method. (e.g. Parse websites, load images)
That was the solution for me because the content is loaded when the app starts up.

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.

UIPickerView that scrolls horizontally on the iPhone?

I'm taking a look at this widget, and it appears to be a UIPickerView, however I haven't seen anything provided by the iPhone SDK API that allows for horizontal scrolling only. Mostly it's all done vertically. Also there appears to be a custom graphic around this picker, so it might not be that either.
I'm curious if anyone is able to determine if this is indeed a UIPickerView or perhaps a hacked up UIScrollView? The widget is handy -- and I like its use. I found it in some random groceries app in the app store.
Here is the screenshot:
Thanks all.
I'd definitely use iCarousel library:
https://github.com/nicklockwood/iCarousel
The library is really well documented, the code is clean and maintained.
That is totally custom. You could indeed do something of the sort overlaying an UIImageView and an UIScrollView. I'd guess it's a 100% custom. As with all programming, there are many ways to do any single thing.
As I recently posted in response to this question, a class for an iOS horizontal picker control (STHorizontalPicker) has just been posted on GitHub. It's nowhere near as sophisticated as UIPickerView, but it provides the basic functionality for picking numeric values and the underlying foundation is probably a good starting point for adding more sophisticated functionality (it's a UIScrollView containing a UIView with multiple CATextLayers for the markers).
It was designed to be used in UITableCellViews and currently looks like this:
This website has source code for a picker that is aligned horizontally without subclassing it.
That definitely looks like a custom component. I'd suggest getting the .app file off your iPhone, opening up the bundle, and looking to see if there's a xib file for that interface. You may get lucky and find the component sitting in there. My guess is that it's a subclass of UIScrollView, but of course there's no way I could be sure of that without personally knowing the developer or the codebase.
You will recognize pickers by their giant screen-gobbling footprint :-) This is most likely a horizontal UIScrollView with a series of fixed-width labels (or images). The tricky bit is to have the bezel on top with a transparent center pass touches back to the underlying scroll view. Or you can take the easy way out and overlay four image strips (for each edge) and leave the middle open so touch events go directly to the scroller.
It's a custom control, but it's really not that hard to build.