nicklockwood/iCarousel — Issue #46: Empty carousel
Author: bvk4you
Created: 2011-10-17 10:34:52+00:00
State: open

Hi Nick,
Iam using I iCarousel as a linear type with wrap Off to display a carousel menu at the top of my view.
The menu items in this view are taken from a server response. So whenever I get new data from the server, I update my model
and call iCarousel reloaddata. The problem is sometimes even though I get the proper data and my model is updating properly ,
after the reload icarousel fails to display anything. Iam not using any placeholders and the no of visible items are no of items in my menu. Here is the code where Iam doing this:
The interesting thing is when I rotate the orientation , then it gets loaded properly ( layoutSubviews is called when the orientation is changed)

- (void)onGettingCatagoryData:(NSArray *)array
{
if(m_categoryArray)
{
[m_categoryArray release];
m_categoryArray = nil;
}
// m_categoryArray = [[NSMutableArray alloc] init];
m_categoryArray = [array mutableCopy];

[m_categoryArray insertObject:m_allDictionary atIndex:0];

NSArray *otherArray = [[SmartClientFWBase sharedSmartClientFWBase] getRootWidgets:NO];
if([otherArray count])
[m_categoryArray insertObject:m_othersDictionary atIndex:([array count] + 1)];

[self creatingButtonsForCarousel:[m_categoryArray count]];

[self.icarousel reloadData];

[self.icarousel scrollToItemAtIndex:0 animated:YES];

}
and here is my viewAtindex method:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index
{
return [m_buttonArray objectAtIndex:index];
}
m_buttonArray is a mutable array created only once and updated in creatingButtonsForCarousel which is called in the above method
Would appreciate any sort of help..
Thanks
Vamshi