I am build an app with ICarousel. There will be around 30 items in the carousel. Each item is a view with UIImageView showing an animation.
Right now I am just creating ahead all 30 views, add them to an array, and supply to the carousel when needed.
SBTViewController* iv1 = [[SBTViewController alloc] initWithNibName:@"SBTViewController" bundle:nil];
SBTViewController* iv2 = [[SBTViewController alloc] initWithNibName:@"SBTViewController" bundle:nil];
.....
.....
SBTViewController* iv30 = [[SBTViewController alloc] initWithNibName:@"SBTViewController_iPhone" bundle:nil];
viewsarray = [NSArray arrayWithObjects: iv1,iv2... iv30]
and when the carousel needs more views - i just supply the views from the array
However, I start getting MemoryWarnings. Tried to use the 'reuseView" option but it simply does not work or I misunderstand something. Each time the following is called :
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
}
I just tried to change the "view" to one of my offscreen views. But it does not seem to work. the carousel shows blank screen.
What is wrong ?
thanks
ReusingView is designed to reduce the need to alloc/dealloc views by recycling them. But because you're storing all your views in a array it won't help you because they are all being created at once and not released anyway.
The problem is fundamentally that you are trying to load too many images into memory at once (number of views x number of animation frames per view).
You'll need to find a way to load the frames dynamically. Try my GLView library (https://github.com/nicklockwood/GLView) which includes instructions for playing animations using PVR images which can be loaded in real time. The GLView library includes a GLImageView class that works just like a UIImageView but let's you specify an array of image filenames to play instead of having to load all the images in advance.