I have implemented iCarousel’s this methods as,
It is getting stick at beginning and after seconds it allows me to scroll. And also i don’t want the images to be overlapped while scrolling i want them all to be having equal distance between each item.
What is wrong in this code? or i am missing anything?
-(void)addiCarousel
{
carousel.frame = CGRectMake(324, 50, 375, 195);
[self.view addSubview:carousel];
self.items = [[NSMutableArray alloc] initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg", nil];
carousel.type = iCarouselTypeCoverFlow2;
[carousel reloadData];
}
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return [items count];
}
- (BOOL)carouselShouldWrap:(iCarousel *)carousel
{
return NO;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
// if (view == nil)
// {
view = [[[UIImageView alloc] initWithFrame:CGRectMake(649, 50, 375 , 195)] autorelease];
view.contentMode = UIViewContentModeCenter;
view.layer.borderWidth = 8.0f;
view.layer.borderColor = [[UIColor blackColor] CGColor];
view.contentMode = UIViewContentModeScaleToFill;
// }
((UIImageView *)view).image = [UIImage imageNamed:[self.items objectAtIndex:index]];
NSLog(@"index : %d",index);
NSLog(@"%@",[self.items objectAtIndex:index]);
return view;
}
After adding below code it stop getting stick and gave smooth scrolling
It was missing,
along with
carousel.clipsToBounds = YES;Might help others.