Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

UICollectionView's didSelectItem isn't called for UICollectionViewController #191

Closed
zocario opened this issue Sep 23, 2020 · 10 comments
Closed
Labels
bug Something isn't working

Comments

@zocario
Copy link

zocario commented Sep 23, 2020

Hello,

I have a new issue related to the last fix made for UICollectionViewController (viewWillAppear not called).
The did select item method isn't triggered in my UICollectionViewController subclass anymore after update to the last version of Family. Also the navigation bar doesn't update its large title to small title when scrolling (it works fine with only a table view).

Steps to reproduce:

  1. Create a FamilyViewController containing a view controller subclassing UICollectionViewController
  2. Present the controller
  3. Override collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) in your UICollectionViewController subclass

Whats happens:

  • The collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) method isn't called on the UICollectionViewController subclass.
  • The navigation bar doesn't update its large title while scrolling

What should happens:

  • collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) should be called correctly.
  • The navigation bar update its large title while scrolling

Sample:
Test family collection view 2.zip

@zenangst
Copy link
Owner

Hey @zocario, thanks for the bug report. I'll get back to you when I've had time to reproduce and examine the issue 😎

@zocario
Copy link
Author

zocario commented Sep 23, 2020

Thanks @zenangst I've updated the issue as there is also the navigation bar not updating its large title while scrolling :)
Sorry to bother you again 🙈

@zenangst
Copy link
Owner

No worries mate, you're not a bother at all!
You are actively making the framework by reporting issues that you find with reproducible examples, I really appreciate that. Issues related using UICollectionViewController have mainly flown under my radar because I don't tend to use them myself. Bringing them up to the surface is a good thing.

The next natural step would be to try and fix the issue yourself by modifying and contributing to the project but let's take it one step at a time 😎

Cheers!

@zenangst
Copy link
Owner

@zocario I figure it out and made a PR for it here #192

It was basically a small "brain-fart" on my part.
We were setting isUserInteractionEnabled to false on the collection view, which we shouldn't do. I'm unsure why I added that to begin with.

Mind trying this branch: fix/collection-view-controllers-selection-issue

Thanks again for the great bug rapports and the sample project.

Cheers!

@zocario
Copy link
Author

zocario commented Sep 29, 2020

Hi @zenangst I did try your fix and yes it works correctly for the items selection. But it doesn't fix for me the problem with the navigation bar not updated when scrolling (switch between large title and standard title). I guess there is some issue with the wrapper view as for a UIViewController with the collection view inside it's working correctly.

Only with UITableViewController

Large title When scrolling
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-09-29 at 08 09 28 Simulator Screen Shot - iPhone SE (2nd generation) - 2020-09-29 at 08 09 25

With UITableViewController and UICollectionViewController

Large title When scrolling
Simulator Screen Shot - iPhone SE (2nd generation) - 2020-09-29 at 08 09 43 Simulator Screen Shot - iPhone SE (2nd generation) - 2020-09-29 at 08 09 41

@zenangst
Copy link
Owner

@zocario oh silly me! I totally forgot about that issue. I'll merge #192 and continue with the other issue on a different branch 😎 Thanks for keeping me in check!

@zenangst
Copy link
Owner

zenangst commented Sep 29, 2020

@zocario it's me again! I think I figure it out based on this Stackoverflow thread - https://stackoverflow.com/a/52035243/65992

So I refactored the UICollectionViewController support in this PR - #196 and now it should work as intended.

Mind taking this branch for a test-run to verify - fix/collection-view-controllers-navigation-bar-issue

Cheers!

@zocario
Copy link
Author

zocario commented Sep 30, 2020

@zocario it's me again! I think I figure it out based on this Stackoverflow thread - https://stackoverflow.com/a/52035243/65992

So I refactored the UICollectionViewController support in this PR - #196 and now it should work as intended.

Mind taking this branch for a test-run to verify - fix/collection-view-controllers-navigation-bar-issue

Cheers!

I've just tested your fix and it looks good to me!
Selection and navigation bar are working as expected 👍

@zenangst
Copy link
Owner

I'll merge and make a new version later today. Out and about with the family today, gonna get us some afternoon tea. 😎

@zenangst
Copy link
Owner

zenangst commented Oct 6, 2020

@zocario 2.0.0 is out now, closing this issue.
Thanks again for the bug report!

@zenangst zenangst closed this as completed Oct 6, 2020
@zenangst zenangst added the bug Something isn't working label Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants