---
title: "Displaying images in UICollectionViewCell from database in iOS"  
description: "Displaying images in UICollectionViewCell from database in iOS"  
author: "Anonymous User"  
published: 2015-11-30  
updated: 2015-12-02  
canonical: https://www.mindstick.com/forum/33662/displaying-images-in-uicollectionviewcell-from-database-in-ios  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# Displaying images in UICollectionViewCell from database in iOS

I am a [beginner](https://www.mindstick.com/forum/23159/need-beginner-project-ideas) in iPhone [app development](https://www.mindstick.com/services/mobile-app-development), I want to [display image](https://www.mindstick.com/forum/33970/how-to-display-image-without-streach-in-uiscrollview) in **UICollectionViewCell** from using database.\
In our [programming](https://www.mindstick.com/articles/12214/web-development-company-in-india-laid-on-the-foundation-of-concrete-java-programming) I am using [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) like this **:**

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

So, my [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) is how can I display those [images](https://www.mindstick.com/interview/1067/what-is-the-php-predefined-variable-that-tells-the-what-type-of-images-that-php-support)?

## Replies

### Reply by Tarun Kumar

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.


---

Original Source: https://www.mindstick.com/forum/33662/displaying-images-in-uicollectionviewcell-from-database-in-ios

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
