gmertk / GMStepper

A stepper with a sliding label in the middle.
https://github.com/gmertk/GMStepper
MIT License
923 stars 114 forks source link

stepper in tableViewCell #18

Open longxianlin opened 8 years ago

longxianlin commented 8 years ago
    let qytStepper = cell.viewWithTag(97) as! GMStepper
    qytStepper.labelFont = UIFont.systemFontOfSize(15.0)
    qytStepper.minimumValue = 0
    qytStepper.layer.borderWidth = 1.0
    qytStepper.layer.borderColor = UIColor.lightGrayColor().CGColor
    qytStepper.tag = indexPath.row
    qytStepper.addTarget(self, action: "stepperValueChanged:", forControlEvents: .ValueChanged)

not working

gmertk commented 8 years ago

Hi @longxianlin, can you elaborate on what is not working?

mihaibulic commented 7 years ago

I'm also having an issue with GMStepper in a tableviewcell.

I don't have the issue quite pinned down yet, but occasionally when quickly scrolling through the list, I'll see this issue:

` @IBAction func onStepperValueChanged(_ sender: GMStepper) { print("stepper (sender.value)) // this line runs 2nd, value is 2 }

// MARK: Local Func
func setContent(quantity: Double) {
    stepper.value = quantity
    print("set content: \(stepper.value)") // this line runs 1st, value is 1

`

kalmicka commented 7 years ago

I am having the same issue. I have the stepper in 10 rows in a Uitableviewcell. If you start scrolling the addTarget method fires even though the button was not touched. I guess it is firing once the cell gets dequeued. Anyway to fix that behavior?

Elshad commented 7 years ago

@kalmicka cell.stepper.value = count Setting value to stepper programmatically also fire .ValueChanged event. Maybe you set value to stepper somewhere in cellForRowAt

Dave181295 commented 2 years ago

Any solution to this?