轮播索引不正确

我有以下plist,我想要在转盘上显示图像。 当我debugging代码时,我看到索引不是顺序的。

在这里输入图像说明

当我在debugging时,首先显示index = 0 ,然后下一个项目是index = 5

 (lldb) po [items objectAtIndex:index]; http://charcoaldesign.co.uk/AsyncImageView/Forest/IMG_0351.JPG (lldb) po [items objectAtIndex:index]; http://charcoaldesign.co.uk/AsyncImageView/Forest/IMG_0358.JPG 

这是实现:

 - (void)awakeFromNib { //set up data //your carousel should always be driven by an array of //data of some kind - don't store data in your item views //or the recycling mechanism will destroy your data once //your item views move off-screen //get image URLs NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Images" ofType:@"plist"]; NSArray *imagePaths = [NSArray arrayWithContentsOfFile:plistPath]; //remote image URLs NSMutableArray *URLs = [NSMutableArray array]; for (NSString *path in imagePaths) { NSURL *URL = [NSURL URLWithString:path]; if (URL) { [URLs addObject:URL]; } else { NSLog(@"'%@' is not a valid URL", path); } } self.items = URLs; } - (void)dealloc { //it's a good idea to set these to nil here to avoid //sending messages to a deallocated viewcontroller carousel.delegate = nil; carousel.dataSource = nil; } #pragma mark - #pragma mark View lifecycle - (void)viewDidLoad { [super viewDidLoad]; //configure carousel carousel.type = iCarouselTypeCoverFlow2; } - (void)viewDidUnload { [super viewDidUnload]; //free up memory by releasing subviews self.carousel = nil; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } #pragma mark - #pragma mark iCarousel methods - (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel { //return the total number of items in the carousel return [items count]; } - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view { //create new view if no view is available for recycling if (view == nil) { view = [[AsyncImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)]; view.contentMode = UIViewContentModeScaleAspectFit; } //cancel any previously loading images for this view [[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:view]; //set image URL. AsyncImageView class will then dynamically load the image ((AsyncImageView *)view).imageURL = [items objectAtIndex:index]; return view; } 

如果有人想testing,这里是github 。 然后select并运行dynamic下载项目

在这里输入图像说明