0
votes

I'm using iCarousel from Nick Lockwood. Excellent work. Having an issue where I need to somehow reset/clear the carousel before loading a new album into it.

background: App pulls XML from an API and parses it into arrays. TableView uses first xml for list of albums. When user selects/taps an album, I push to view with iCarousel. User can back up and choose another album

Works fine first album. Works fine as long as any album picked after has as many or more pics as the first. Bombs when user picks an album with less pics than the first album chosen.

Err is in:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
...//('thumbs' is thumbnail array)
 APIContentObject *currentPhoto = [thumbs objectAtIndex:index];        
...
}

hoping to sync up my array to iCarousel, it'll bomb trying to load '[thumbs objectAtIndex:index]' when index is 6 and the array.count is 4...

I have tried carousel=nil; on viewWillDisappear, nope. is I do a carousel=nil; in ViewDidLoad, I get nothing... When is it instantiated? before ViewDidLoad?

I really just need to know how to empty it or clear it or relloc/init it. I tried a 'for' loop to manually removeitematindex each one but I have errors there too..

It does work, just not as expected. Lil' advice? Much appreciated.

EDIT: ok, when I use:

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel
{
    //return the total number of items in the carousel
    return [thumbs count];
}

to set the amount of visible items...this seems to be a point of interest. If I DON'T set it/use this block of code, then only 7 or so images show up... If I set it, they all show up, but then it bombs when hitting an album with less image count. I'm running around in circles on this one.

1

1 Answers

0
votes

Got a clue from reading another post about a recycling problem.

I had my my call to load the image inside the recycler...(ProgrammerError *ME!)

if (view == nil)
    {...
    [((FXImageView *)view) setImageWithURL:[NSURL URLWithString:currentPhoto.ThumbnailURL] placeholderImage:[UIImage imageNamed:@"loading.png"]];
    ...}

moved it outside the condition and whamo... all better.