How to use UIStepper

后端 未结 5 405
無奈伤痛
無奈伤痛 2020-12-13 09:06

I am trying to work with UIStepper to increment or decrement an integer, but both \"-\" and \"+\" increase the integer! How can I recognize the \"+\" and \"-\

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 09:36

    You should ignore the ivars. They will not help you.

    The UIStepper has a value property that you can query to figure out what the current value is. So your method could simply be:

    - (IBAction)valueChanged:(UIStepper *)sender {
      double value = [sender value];
    
      [label setText:[NSString stringWithFormat:@"%d", (int)value]];
    }
    

提交回复
热议问题