views:

464

answers:

1

I need help getting dataSource in OpenFlow. I

I want to provide CoverFlow functionality whenever the phone is turned horizontally. I'm using Alex Fajkowski's awesome code OpenFlow ( http://fajkowski.com/blog/2009/08/02/openflow-a-coverflow-api-replacement-for-the-iphone/ ) but the example provided is very different than what I need.

I am using OpenFlow in a horizontal view inside a navbar view controller. I have OpenFlow working already. I can scroll through all my images and works really good. However I am using it with over 100 images and it takes a while to load at first. In looking into performance improvements I realized the AFOpenFlowViewDataSource delegate is not getting called. I was able to get AFOpenFlowViewDelegate working by specifying the delegate in the view controller class "flowView.dataSource = self;". But I am not able to get the datasource delegate working. Not even with "flowView.viewDelegate = self;".

Is the datasource needed at all? It seems it is needed for threading of loading.

+1  A: 

Ok, it looks like it is running beautiful now. The DataSource delegate is only called when there the objects are loaded dynamically. Meaning, if I use "[(AFOpenFlowView *)self.view setImage" then dataSOurce is never called because all it knows images are already loaded. However, using "[(AFOpenFlowView *)self.view setNumberOfImages:30];" triggers the DataSource delegate to load the images as they are needed. I found the GetImageOperation NSThread very useful for my 100+ images. However, images are not unloaded after going offscreen. Anyone know how to unload images as they go off screen?

It seems the problem comes from a mutable array that grows as each view is added. This array is great for a small amount of objects but it becomes a memory hog when there are a lot of objects. I solved it by simply commenting out the line where the array line.Inside AFOpenFlowView.m look for - (void)setImage:(UIImage *)image forIndex:(int)index and comment out the following lines://[coverImages setObject:imageWithReflection forKey:coverNumber];//[coverImageHeights setObject:[NSNumber numberWithFloat:image.size.height] forKey:coverNumber];