Beginning Collection Views | raywenderlich.com

<p>Learn all about using collection views in iOS to build composable and flexible layouts both in code and using Interface Builder. You’ll learn how to implement custom cells, animate changes and work with different types of data sources</p>


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5429927-beginning-collection-views

Is this course relatable to SwiftUI? I am asking because I am creating an app using collection views and I do not know if they are part of SwiftUI.

Nope. Some features work but the diffable data source not. I also asked the author about that since I was struggling to implement it in SwiftUI but as I see he just deleted my question without any answer.

@hastoro11 :weary: Apologies if I did, definitely didn’t intend to! The short answer is no SwiftUI does not have a built in implementation for collection views. My SwiftUI knowledge is somewhat limited but I think you would implement it using an HStack and ForEach views. The official Apple tutorial implements it this way if I remember correctly

Very good class! Pasan is an excellent instructor.

1 Like

Thanks for the great class Pasan.
Can you help me add some features to it, I need to make the collection views sections collapsable and user can expand on click.

Man, you did it! Congratulations, excelente course! I’d like to see you teaching us the same way about TableViews, that is already outdated.

1 Like

@montyp @ygornascimento @bahaahany Really glad you like it! Cheers! :]

@bahaahany Do you still have issues with this?

How is it possible to access an item at a certain location? I’ve added a textField to the cell and would like to do something with this text, however whenever I try to access the collection view with a function from within the ViewController class, it get an error that the collectionView is nil.

for example I’m trying to get index path for the cell containing a textField I’ve selected by using its CGPoint and collectionView.indexPathForItem(at: )

Does every cell have a text field? Can you maintain a reference to the text field instead of accessing it through the cell? You can also use the text field’s delegate methods to get access to the text. Using a CGPoint instance won’t always give you the same cell if the list is scrolled, or if the list is edited