I have a UITableView with heavy images content. So the scrolling is not fluid anymore.
I want to add a timer to load the images, while you scroll I create the timer for each row. If the cell quits the view, I cancel the timer. If not I fade in the images.
My question is : is there a callback for a cell going out of view ? I’m reading the doc, but I’m not sure there is anything for my needs.
Thanks for the help !
EDIT: The code I’m using (this is the three20 library, I’m using a custom TTTableItemCell. The “_tabBar1.tabItems = item.photos” is the line hoging resources. On the first load it’s okay because the photos are being loaded asynchronously from the server, but when I scroll back or reload the view, they are all loaded synchronously, and the scrolling isn’t smooth anymore, especially on an iPhone 3G. :
- (void)setObject:(id)object {
if (_item != object) {
[super setObject:object];
Mission* item = object;
self.textLabel.text = item.name;
_tabBar1.tabItems = nil;
timerFeats = [NSTimer scheduledTimerWithTimeInterval:(0.5f) target:self selector:@selector(updateFeats) userInfo:nil repeats: NO];
//_tabBar1.tabItems = item.photos;
}
}
-(void)updateFeats {
DLog(@"timer ended");
Mission* item = self.object;
self._tabBar1.tabItems = item.photos;
}
Alright, I found a way.
There is actually a callback to know what cell is about to get out of view. :
So my code is :
If there is no newSuperview the cell is going out of the view and so I verify first that my timer hasn’t been invalidated yet, and then I cancel it.