Beginning Collection Views - Part 4: Section 1: | Ray Wenderlich

What happens when you tap on a cell? In this challenge, implement basic cell selection using your knowledge of Table Views.


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

Hi,I am doing collection view series now.Tutorials are very useful but I find customization of collection view cells to be confusing and is not clear like CGSize bit and let widthSize = (view.frame.size.width - 20) / 3 why we did that please guide me with some solution so that I can understand it more accurately. I really find the content and your efforts very helpful

Thanks
Vinney

That calculation is for when you need 3 columns of cells in your collection view. Since the screen size can vary depending on device, you take the width of the screen, which is view.frame.size.width, and divide it by 3 to get the size of each column. However, you also want 10 pixels of space between each column. Since you have 3 columns, you’ll have two spaces between those 3 columns and so, 10 x 2 = 20 and that’s the amount of space you take out before you the division to allow for the space between the columns.

Hope that clarifies things?

1 Like