Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get "indexPath.section" in a UICollectionView? #16

Closed
dkmczk opened this issue Mar 17, 2017 · 2 comments
Closed

How to get "indexPath.section" in a UICollectionView? #16

dkmczk opened this issue Mar 17, 2017 · 2 comments
Assignees
Labels

Comments

@dkmczk
Copy link

dkmczk commented Mar 17, 2017

Thank you for the great project!!
When I tapped a collectionView, how can I get "indexPath.section"?
I could get indexPath.item but indexPath.section always returns "0".

func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { print(indexPath.section) print(indexPath.item) }

Thank you!

@giulio92
Copy link
Owner

giulio92 commented Mar 17, 2017

Hello @dkmczk,

To get the indexPath for a given UICollectionView you should rely on the UITableView delegate instead of the UICollectionView one, since you would have a UICollectionView for each UITableView section, and every collection is separated from the other one. You would have a UICollectionView indexPath.section greather than "0" only in the case you would have two UICollectionView inside a given UITableView section

@giulio92 giulio92 self-assigned this Mar 17, 2017
@dkmczk
Copy link
Author

dkmczk commented Mar 17, 2017

Thank you so much I understood!
I will use UITableView delegate instead.

@dkmczk dkmczk closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants