How to get selected IndexPath from a stepper located inside a collection view cell?

前端 未结 3 1472
刺人心
刺人心 2021-01-27 03:41

I have collection view that has stepper inside the collection view cell used to increase the number of product like the image below.

I need to know, when I clic

3条回答
  •  醉话见心
    2021-01-27 03:58

    You can try adding tag property to the stepper. So when you click on the stepper you can listen to its selector and determine which stepper was called. The tag value should be same as the item index.

    Something like this

    cell.stepper.tag = indexPath.row
    

    Above code should go inside the cellForRowAt delegate function.

    and then when user taps on the stepper call a function and check the tag value

    Something like this

    func stepperClicked(sender) {
        //check sender.tag value
        //Do something here with the tag value
    }
    

提交回复
热议问题