Displaying images in UICollectionViewCell from database in iOS

Total Post:10

 986  View(s)
Rate this:

I am a beginner in iPhone app development, I want to display image in UICollectionViewCell from using database.
In our programming I am using code like this :

SqliteDB *images;
images = [SQliteDB alloc] init];
imgArray = [images OpenMyDatabase: @"SELECT images FROM exterior" :


So, my problem is how can I display those images?

  1. Post:214

    Re: Displaying images in UICollectionViewCell from database in iOS

    Use my code to display UIImage grid. and add uicollectionView in your xib file.

    - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
       return  1;

    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
       return [imgArray count];

    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
       static NSString *identifier = @"Cell";

       UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:

    identifier forIndexPath:indexPath];

       UIImageView *imgView = (UIImageView *)[cell viewWithTag:100];
       imgView.image = [UIImage imageNamed:[imgArray objectAtIndex:indexPath.row]];

       return cell;

    and, don't forget to set delegate in collection before using that code.
    and also in your xib file add UIImageView to your collection view cell and set its tag value to 100.



Enter your email address here always to be updated. We promise not to spam!