Cell button action not works instead of that cell didselect row calls swift || collection View button action not works instead of that cell didselect row calls swift || didselect called while tapping button in collectionview swift

Problem:

I had a cell with button and some set of views.I added the target to that button.If i clicked that button target calls and also the cell didselect row calls.

How to disable the didselect call in button click action.


Solution:


If you added the target then didselect also will be called.So you must avoid add target to a button in a cell.Instead of you can add the tap gesture to the button and call the action.It will avoid to call didselect method.


                  let singleTap = UITapGestureRecognizer(target: self, action:#selector(self.didTapAction(_:)))

                  singleTap.numberOfTapsRequired = 1

                  Cell.Btn.addGestureRecognizer(singleTap)


Comments

Popular posts from this blog

Invalid bundle error while upload the app to the app Store

Convert NsNumber, NSDate to String in iOS Swift

Global LocationManager Singleton class iOS Swift