Closed Raviron closed 6 years ago
Finally figured it out. The example sets the iCarousel.tag value AFTER it is needed. Setting the dataSource value on a carousel triggers the nested calls to numberOfItemsInCarousel and viewForItemAtIndex. So all you have to do is assign the tag immediately after creating the nested carousel, as follows:
(UIView )carousel:(iCarousel )carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView )view { if (carousel == _carousel) { //item for outer carousel iCarousel subCarousel = (iCarousel *)view;
if (view == nil)
{
subCarousel = [[iCarousel alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 200.0f, self.view.bounds.size.height)];
subCarousel.tag = index; // New location
subCarousel.dataSource = self;
subCarousel.delegate = self;
subCarousel.vertical = YES;
subCarousel.type = iCarouselTypeCylinder;
view = subCarousel;
}
//configure view
//you might want to restore a saved scrollOffset here
//but for now we'll just set it to zero
subCarousel.scrollOffset = 0.0f;
//subCarousel.tag = index; // Old location
} ...
Hope this helps, and thanks Nick Lockwood for the carousels. cheers
Hello, I'm having problems with the nested carousel example. It looks like it runs properly but the data from the first carousel gets copied to the rest. When I changed the data generator to the following:
Specifically I noticed that setting iCarousel.tag seems to have no effect. Is this a bug or am I missing something? Thanks