# Swift Expanding Cells in iOS Collection Views

**URL:** <https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622>\
**Category:** 🎓 Courses & Articles\
**Created:** [March 4, 2016, 10:56am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622 "2016-03-04T10:56:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisintx](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chrisintx/32/287_2.png) [@chrisintx](https://forums.kodeco.com/u/chrisintx)\
**Post date:** [March 4, 2016, 10:56am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/1 "2016-03-04T10:56:13Z")

</div>

Learn how to make expanding cells as in the Ultravisual app in this tutorial on collection views.

* * *
 This is a companion discussion topic for the original entry at [https://www.raywenderlich.com/1709-swift-expanding-cells-in-ios-collection-views](https://www.raywenderlich.com/1709-swift-expanding-cells-in-ios-collection-views)

---

<div class="post-metadata">

**Author:** ![pongoly](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/pongoly/32/30852_2.png) [@pongoly](https://forums.kodeco.com/u/pongoly)\
**Post date:** [April 18, 2016, 8:22am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/2 "2016-04-18T08:22:48Z")

</div>

Thank you for this tutorial Chris. What other resources do you recommend for learning more about design in iOS? I’d like to make more apps that are nice to look at and fun to interact with while still being functional (i.e. presenting some content or service other than nice looking transitions).

---

<div class="post-metadata">

**Author:** ![gaurang9007](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gaurang9007/32/33223_2.png) [@gaurang9007](https://forums.kodeco.com/u/gaurang9007)\
**Post date:** [May 28, 2016, 8:14am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/3 "2016-05-28T08:14:27Z")

</div>

Nice tutorial. Can you please let me know how to achieve the animation without overlapping of images. It should shrink from bottom and expand from top part of the cell. It should not overlap each other like stack. I tried with many ways using this tutorial but unable to achieve.

---

<div class="post-metadata">

**Author:** ![gaurav\_singh](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gaurav_singh/32/38644_2.png) [@gaurav\_singh](https://forums.kodeco.com/u/gaurav_singh)\
**Post date:** [August 10, 2016, 12:35pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/4 "2016-08-10T12:35:05Z")

</div>

Thanks for the great tutorial. How can make this to show the featured cell in the bottom instead of top. I want replicate this functionality to show the bottom cell as feature but unable to figure out the frames for the cells in prepare layout, calculating featuredItemIndex and calculating scroll offset to stop on the last visible cell.

---

<div class="post-metadata">

**Author:** ![doc](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doc/32/109025_2.png) [@doc](https://forums.kodeco.com/u/doc)\
**Post date:** [September 19, 2016, 12:50pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/7 "2016-09-19T12:50:34Z")

</div>

In iOS 10 with Swift 3 the layout seems to be broken. Does anyone have an idea why that is? Thanks

---

<div class="post-metadata">

**Author:** ![famictech2000](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/famictech2000/32/81494_2.png) [@famictech2000](https://forums.kodeco.com/u/famictech2000)\
**Post date:** [September 25, 2016, 3:06am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/9 "2016-09-25T03:06:16Z")

</div>

Have you been able to get the solution working for iOS 10 with Swift 3.0!?

---

<div class="post-metadata">

**Author:** ![doc](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/doc/32/109025_2.png) [@doc](https://forums.kodeco.com/u/doc)\
**Post date:** [September 25, 2016, 8:50am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/10 "2016-09-25T08:50:40Z")

</div>

It’s because of the prefetching feature of UICollectionView in iOS 10. This restores the previous behaviour for now:

```
if #available(iOS 10.0, *) {
    collectionView!.isPrefetchingEnabled = false
}

```

---

<div class="post-metadata">

**Author:** ![famictech2000](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/famictech2000/32/81494_2.png) [@famictech2000](https://forums.kodeco.com/u/famictech2000)\
**Post date:** [September 25, 2016, 12:27pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/11 "2016-09-25T12:27:43Z")

</div>

Thanks for your reply!

---

<div class="post-metadata">

**Author:** ![chetan\_kasundra](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/chetan_kasundra/32/67429_2.png) [@chetan\_kasundra](https://forums.kodeco.com/u/chetan_kasundra)\
**Post date:** [September 29, 2016, 2:57pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/12 "2016-09-29T14:57:25Z")

</div>

Thank you for this tutorial, Chris. I need a small help. I want to scroll at particular indexPath but It’s not working.

` collectionView!.scrollToItemAtIndexPath(NSIndexPath(forItem: 6, inSection: 0), atScrollPosition: .Top, animated: true)`

I have used this code but It’s not working.If I am using the wrong syntax or is there any extra code is required for that.

---

<div class="post-metadata">

**Author:** ![daver235](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/daver235/32/101102_2.png) [@daver235](https://forums.kodeco.com/u/daver235)\
**Post date:** [October 17, 2016, 12:40am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/13 "2016-10-17T00:40:33Z")

</div>

Where does this fix go? I’m now crashing after converting to Swift 2.3 at cellForItemAtIndexPath when I scroll.

Thanks,  
Dave

---

<div class="post-metadata">

**Author:** ![johnlacs](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/johnlacs/32/44512_2.png) [@johnlacs](https://forums.kodeco.com/u/johnlacs)\
**Post date:** [October 17, 2016, 10:57am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/14 "2016-10-17T10:57:53Z")

</div>

Has anyone tried adding a navigation bar to collectionview controller with the ultravisual layout? There seems to be some sort of error where the search bar is not clickable. Bar button items on the navigation bar work fine, but the embedded search doesnt seem to work at all and is unclickable.

---

<div class="post-metadata">

**Author:** ![famictech2000](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/famictech2000/32/81494_2.png) [@famictech2000](https://forums.kodeco.com/u/famictech2000)\
**Post date:** [October 21, 2016, 8:10pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/17 "2016-10-21T20:10:35Z")

</div>

can you show the code.

---

<div class="post-metadata">

**Author:** ![fredflinstone](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fredflinstone/32/49835_2.png) [@fredflinstone](https://forums.kodeco.com/u/fredflinstone)\
**Post date:** [November 29, 2016, 3:53pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/18 "2016-11-29T15:53:29Z")

</div>

Have you found a solution?

---

<div class="post-metadata">

**Author:** ![fredflinstone](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/fredflinstone/32/49835_2.png) [@fredflinstone](https://forums.kodeco.com/u/fredflinstone)\
**Post date:** [November 29, 2016, 3:54pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/19 "2016-11-29T15:54:18Z")

</div>

Did you manage to make it work?

---

<div class="post-metadata">

**Author:** ![aka77](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/aka77/32/81494_2.png) [@aka77](https://forums.kodeco.com/u/aka77)\
**Post date:** [February 10, 2017, 12:31pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/20 "2017-02-10T12:31:49Z")

</div>

Is there an up to date tutorial?

---

<div class="post-metadata">

**Author:** ![famictech2000](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/famictech2000/32/81494_2.png) [@famictech2000](https://forums.kodeco.com/u/famictech2000)\
**Post date:** [April 5, 2017, 12:32am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/21 "2017-04-05T00:32:41Z")

</div>

Is there anyway (or has anyone already done so) to add a section footer at the end of the collection view!? It doesn’t allow for the option to Enabled Section Header in the Attributes Inspector of the Storyboard!?

---

<div class="post-metadata">

**Author:** ![guduruvamshi93](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@guduruvamshi93](https://forums.kodeco.com/u/guduruvamshi93)\
**Post date:** [April 30, 2017, 4:45pm UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/22 "2017-04-30T16:45:03Z")

</div>

Please find the tutorial in Latest Swift syntax here:  
[https://github.com/VamshiIITBHU14/ExpandingCollectionView](https://github.com/VamshiIITBHU14/ExpandingCollectionView)

---

<div class="post-metadata">

**Author:** ![freddygump](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/freddygump/32/68873_2.png) [@freddygump](https://forums.kodeco.com/u/freddygump)\
**Post date:** [July 8, 2017, 8:27am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/25 "2017-07-08T08:27:35Z")

</div>

Any idea how I can hook up buttons to the cell elements? That whenever I would press on one of the cells, there would be a new view with more details about the cell that just got pressed?

---

<div class="post-metadata">

**Author:** ![shahriar](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@shahriar](https://forums.kodeco.com/u/shahriar)\
**Post date:** [August 24, 2017, 4:26am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/26 "2017-08-24T04:26:24Z")

</div>

I am new in swift. I have downloaded the final project and the list shows duplicate images at the same location.

When converted into swift3 it shows error in UltravisualLayout.swift.  
The problem resolved by changing the method signature to  
`override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]?`

Then I have to override another function in UltravisualLayout.swift

> ```
> override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes?{
> return cache[indexPath.item]
> }
> 
> ```

But now it shows duplicate elements in list.  
Maybe I have to work with `override func prepare()` function

---

<div class="post-metadata">

**Author:** ![shogunkaramazov](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/shogunkaramazov/32/108826_2.png) [@shogunkaramazov](https://forums.kodeco.com/u/shogunkaramazov)\
**Post date:** [August 24, 2017, 7:39am UTC](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622/27 "2017-08-24T07:39:49Z")

</div>

This tutorial is more than six months old, so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]

[Next page](https://forums.kodeco.com/t/swift-expanding-cells-in-ios-collection-views/6622.md?page=2)
