Can you set a default/current value for UIStepper

2019-07-28 08:00发布

I tried to do something like this in the viewDidLoad method:

 self.myStepper.value = 10.0;

But it's not working. I've googled and googled and I can't find any answers to this. It seems so easy for a slider, but can you do it with a stepper as well?

3条回答
The star\"
2楼-- · 2019-07-28 08:48

We can set the Value for the Stepper using the Below Syntax,

[your_stepper_name setValue:your_stepper_value];

ex:

[stepper setValue:10];

查看更多
叼着烟拽天下
3楼-- · 2019-07-28 08:52

I figured it out, I simply forgot to init the steppers in the viewDidLoad method. Sorry guys!

查看更多
Fickle 薄情
4楼-- · 2019-07-28 08:55

Stepper values need to be within bounds of min and max, or like in the comments to your question they get pushed to either the min or max. Always check Apple's Reference docs.
Reference: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIStepper_Class/Reference/Reference.html

enter image description here

查看更多
登录 后发表回答