i use iCarousel lib as a scroll view for my app. The purpose of that library is to manage auto scrolling images. Image is set as a bounds of iCarousel class (which is actually UIView
. It work fine, when initially loaded, but when i rotate device, it output odd bug. For example if i swipe from portrait to landscape, for fraction of second we can see following:
For some reason we see "old" pictures
Here is how i declare main method for displaying views:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view {
NewScrollerItemForIPad *item;
NewsItemMdl *mdl = self.viewModel.arrNews[index];
if(mdl){
/* Check for orientation */
BOOL _isPortrait;
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)){
_isPortrait = NO;
} else {
_isPortrait = YES;
}
if (self.gotNews){
if(!item){
item = [[NewScrollerItemForIPad alloc] initWithFrame:car.bounds andOrientation:_isPortrait];
}
[item bindViewModel:mdl];
}
}
return item;
}
And auto scrolling method:
-(void)runMethod{
if(self.sliderCount== (self.pageControl.numberOfPages-1)){
NSLog(@"Here we call");
self.pageControl.currentPage = 0;
self.sliderCount = 0;
[car scrollToItemAtIndex:self.sliderCount animated:YES];
}else{
NSLog(@"And here we call");
self.sliderCount++;
self.pageControl.currentPage ++;
[car scrollToItemAtIndex:self.sliderCount animated:YES];
}
}
How to fix that bug? Obviously i dont want to future and old image to be loaded between new.
iCarousel
, but I can tell you its implementation and behaviour are very-very odd (mostly buggy) – what we did to resolve the problems after orientation has changed we invoke the–reloadData
method on the actualiCarousel
instance every occasion. – holex