如何确定轮播的索引?还是加载了数组的索引?我已经从 NSDocumentDirectory 加载了我的图像。
self.myImages = [NSMutableArray new];
for(int i = 1; i <= 30; i++)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"myImages%d.png", i]];
if([[NSFileManager defaultManager] fileExistsAtPath:savedImagePath]){
[images addObject:[UIImage imageWithContentsOfFile:savedImagePath]];
NSLog(@"file exists");
}
}
并将它们添加到 iCarousel 视图中:
- (UIView *)carousel:(iCarousel *)_carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
view = [[UIImageView alloc] initWithImage:[myImages objectAtIndex:index]];
return view;
}