Question

i have try to create a simple photo browser, and i used UICollectionView, when i try to insert them thumb images to the cell, it does't work,it has a thread, but i can't fixed it,please help me, thank you very very much. here is my code:

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView   cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ImageCell";
ImageCell *cell = (ImageCell *)[collectionView     dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];

NSArray *images =    @[@"http://www.example.com/p1.jpg",@"http://www.example.com/p2.jpg",@"http://www.example.com/p3.jpg",@"http://www.example.com/p4.jpg"];
cell.imageView.image = [UIImage imageNamed:images[indexPath.row]];

return cell;
}
Was it helpful?

Solution

You can also use SDWEBIMAGE. thus you can use

[cell.imageView setImageWithURL:[NSURL URLWithString:@"Your image url"]
                   placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

see this link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top