You don't load 60-70 view controllers. You only have the number of view controllers on the screen, and when the view scrolls (say) down, you take the controller at the top, change the graphic for one you have stored and put it at the bottom.
Up vote 1 down vote favorite 2 share g+ share fb share tw.
The iPad app I am designing is going to show a full screen UIScrollView allowing the user to flick through a large number (200 or more) of images - all the same size, no paging. The images are to be loaded from the web and don't have a predefined ordering. Right now what I do is I load and parse an XML feed which contains references to the images I load, plus metadata which I am showing on the flip side.
I store all this in separate objects that manage a front and back view and flipping between those. The created objects' views are placed on the UIScrollView in a grid, showing a placeholder image at first. As soon as the image URL is set in the object, it fetches the image itself using an `NSURLConnection`.
When the image is fully loaded, it replaces the placeholder image. This works well enough for a limited number of objects (even though the UI is unresponsive at times), but it does not scale up. The app crashes when I load more than 60-70 custom view controllers.
Most of these are offscreen of course - the images are 280x280 each so only 12 will be visible at any given time. I guess I need to find a way to still keep loading the data in the background but to manage keeping only those views that are actually on (or near) the visible extent of the UIScrollView. Do I need to use Core Data to manage this?
If you handled a similar challenge I would love to hear how you solved this - I am guessing it is quite a common one. Iphone cocoa-touch uikit uiscrollview link|improve this question edited Aug 10 '10 at 7:55Peter Hosey53.4k445137 asked Aug 10 '10 at 7:47mvexel565316 80% accept rate.
Peter Hosey - I added the core data tag because I am considering using core data for this and as such the question indirectly has to do with (appropriateness of) usage of CD. – mvexel Aug 10 '10 at 8:48 Core Data takes care of the model section of your app. Managing views (including reusing view controllers) is not a model task.
– Peter Hosey Aug 10 '10 at 9:10.
You don't load 60-70 view controllers. You only have the number of view controllers on the screen, and when the view scrolls (say) down, you take the controller at the top, change the graphic for one you have stored and put it at the bottom. The others you are loading you can download in the background.
You don't need core data (although you can use it if you want to). Have a look at the apple videos on scroll views, they cover this.
– mvexel Aug 10 '10 at 8:48 I don't have iTunes here, but there are a set of earlier WWDC (maybe 08) that conver it in depth. Have a watch of the videos on table views, they go into it in depth and are very easy to follow, with demonstrations of concepts and code required. – Woody Aug 10 '10 at 11:26 What I ended up doing is somewhat similar but I am not sure if the results are the same.
What I do now is keep a set of integer variables minVisibleColumn, maxVisibleColumn, minVisibleRow and maxVisibleRow in the view controller that manages the scroll view. These get updated in scrollViewDidScroll: . The Cover objects (which manage the individual views on the scroll view) are assigned a row and column when they are initialized and observe these values.
They then add and remove themselves from the scroll view depending on visibility. Does that make sense as a solution? – mvexel Aug 17 '10 at 6:19.
This is how I did this. I only showed 3 UIView's at the time and every time the user goes forward I unload the first UIView and load a new UIView. The user doesn't notice this, because the next screen and previous screen are always loaded (3 UIViews).
I am trying hard to find a solution as my scrolling is really really slow. – Praveen S Mar 5 '11 at 11:48.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.