I have implemented a UIScrollView on the iPhone that contains 100 image slots which I fill only the currently visible page, the one before it, and the one after it as the user scrolls.
Everything works fine until we get up to image 97 or 98, the entire view disappears! The only thing I can do at that point is navigate back to the previous view.
Nothing works as far as the scroll view after this. I am not receiving any memory warnings an the rest of the app functions fine. Any ideas? Has anyone created a UIScrollView in paging mode with over 100 pages?
Rick
you might want to look into using the Three20 library.
http://three20.info/ (open source and commercial friendly license)
It has an 'image container', might save you some time on re-inventing the wheel.
Related
In my app I have a bit where the user can take a photo and it get dropped into a list and the user could technically forever keep adding photos.
So what is the best way of saving, storing and loading the photos the user takes? Taking into account, there could be hundreds. Also, loading them all in at once might not be a smart idea as well, but say have a scroll view, scroll down, and when hitting the bottom it could load say 20 more and then another 20, etc.
Any help, much appreciated, thanks.
Just decide where you want to store the photos, built-in photo library or apps documents folder or both (I'd go with photo library for users's convenience in watching, deleting, synchronizing etc.). If you choose documents folder, don't forget to support deleting ... Disk space is the users problem.
If you choose only to store in photos library and want access the photos later from within the app, you have to save the urls of the saved images. This answer tells you how it works.
Loading the photos in scroll view will need some optimization, i.e. it wouldn't be a good idea to load all photos in memory, but only the visible ones. As another answer says, the re-use of cell in UITableView could be a solution, but I think, UITableView is for the typical iPhone table, adjusting and customizing it and its UITableViewCells isn't worth it, if the only reason is memory usage.
I'd go with UIScrollView and react upon the delegate's methods to load new content and drop old one. If you want a non-paging UIScrollView you should use scrollViewDidScroll , which is fired really often, so maybe there will be need for another optimization - test it. A paging UIScrollView seems to be easier to me. Just react on scrollViewDidEndDecelerating for loading and dropping content.
Hope that helps.
use tableview, it will load it manages the memory and jst visible rows are loaded into memory if u use dequecell method
read tableview more here
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html
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)
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.
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.)
I would like to take a stack of images (or potentially an array of URLs to download images) and display them in full screen, one at a time, using user swipes to smoothly animate the next image in the stack, using the iPhone SDK. Apple's Photo.app seems to do this. Additionally, if the image has not been retrieved yet, I'd like to display the progress indicator.
Can you point me to example code and explain how this technique would be implemented?
You need to use UIScrollview's page control mechanism. Apple has plenty of sample code, including one called, strangely enough, Page Control:
http://developer.apple.com/iphone/library/samplecode/PageControl/index.html
If you want any behavior beyond that, you'll have to roll it yourself.