Using Swift, why when pressing one UIStepper affect both steppers?

1.1k views Asked by At

I am writing an application in Swift 3.0 using xCode.

I have two steppers on the iPhone and when I press one of them, both text boxes are affected. I only want one text box to be affected. ]

Does it have something to do with sender.value? How do I state specifically when I want only one label to be affected?

Here is my code:

    //the birthdate action that will increase or decrease the age
@IBAction func birthdateStepperAction(_ sender: UIStepper) {
    //when the age stepper is pressed, the value is sent to the textbox
    actualAgeLbl.text = String(sender.value)
}

//the weight action that will increase or decrease the weight
@IBAction func weightStepperAction(_ sender: UIStepper) {
    //when the weight stepper is pressed, the value is sent to the textbox
    actualWeightLbl.text = String(sender.value)
}

Here is before pressing the stepper: first picture before pressing stepper

Here is after pressing the stepper second picture after pressing stepper

Thanks in advance.

1

There are 1 answers

0
Jack On BEST ANSWER

Probably you are connected with same @IBAction for two stepper. See below screen shot-

enter image description here