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

前端 未结 3 1470
刺人心
刺人心 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 04:11

    You have the stepper because it is the sender in your action method. The stepper has a superview which is the cell (you might have to walk up more than one superview to reach the cell). Once you have the cell you can call indexPath(for:) to get the index path. Done.

    https://developer.apple.com/documentation/uikit/uicollectionview/1618094-indexpath

提交回复
热议问题