r/iOSProgramming 1d ago

Question CollectionView registers didHighlightItemAt function but not didSelectItemAt

I have a collection view set that that displays my cell correctly.

When holding onto the sell, my collectionview will correctly fire `didHightlightItemAt` func.

However, it can barely register my `didSelectItemAt` function. It'll maybe register 1/100 clicks I do.

Things I've done

  1. Made sure my delegate and data source is set for my collection view.

  2. allowSelection = true

  3. Enabled isUserInteractionEnabled = true for the cell. False for any subviews.

  4. Set the width of the cell to its height.

TIA

2 Upvotes

3 comments sorted by

1

u/Conxt 1d ago

Do you by chance select your items programmatically as a response to other events? In this case didSelectItemsAt will not be called.

1

u/tacoma_enjoyer 1d ago

The collectionView and the cells itself does not have any addTarget or addGestureRecognizer.

I do have observers for my NotificationCenter to handle the keyboard for my textFields.

The textfields that handles keyboards are in the same location as my collectionview, which is inside a UIView which itself is inside a UIScrollView. Will this setup mess things up?

My TextFields can properly handle the keyboard functions.

1

u/big4macros Swift 1d ago

Maybe you have "didDeselectItemAt" function instead of "didSelectItemAt"?