Closed aur0n closed 12 years ago
I see a couple of potential problems here:
1) You are misusing the reusingView property. Views are recycled as the carousel scrolls, like a tableview. If you don't set the image each time, some carousel items will end up with the wrong images because they will be using a recycled view from elsewhere in the carousel.
2) I don't think the imageNamed: method works with files outside of the application bundle (I may be wrong about that - I've not actually tried it).
You can load your items using the code below instead, but loading images this way doesn't cache the loaded image, and loading images as the carousel scrolls may not perform well, so a better idea may be to store your downloaded images in memory in an array, or use something like my AsyncImageView class which downloads and caches images on the fly.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
if (view == nil)
{
view = [[UIImageView alloc] init];
}
NSString* foofile = [documentsPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", [arr_ids objectAtIndex:index]]];
UIImage *image = [UIImage imageWithContentsOfFile:foofile];
((UIImageView *)view).image = image
((UIImageView *)view).frame = CGRectMake(0,0, image.size.width, image.size.height);
return view;
}
Oh my god, thank you so much! I wasn't expecting such a quick response!
It solved my problem, hurray! Thank you again and keep up the great work -- iCarousel is just awesome.
Hello guys, I've a really weird problem.
When apps launch, it downloads some images and stores them locally (I also have an array, called 'arr_ids', which stores the filenames).
A typical location: /Users/Mahmood1/Library/Application Support/iPhone Simulator/5.1/Applications/B6F38D3B-D801-46C5-ACEE-1A2FF36CF14F/Documents/248646.png
When I try to view them with iCarousel for iOS, nothing appears. It's like the images doesn't exist (but I'm sure they does: I tried to make a temp UIImageView with the image path which is the same exact location I give to iCarousel, and it loads).
Please help, I really can't understand the problem. Thank you.