xcode 您可以为 UIStepper 对象设置默认/当前值吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13805263/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:16:47  来源:igfitidea点击:

Can you set a default/current value for UIStepper object?

objective-ciosxcodeuistepper

提问by SISYN

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

我试图在 viewDidLoad 方法中做这样的事情:

 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?

但它不起作用。我用谷歌搜索和谷歌搜索,我找不到任何答案。滑块看起来很容易,但你也可以用步进器来做吗?

回答by propstm

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

步进值需要在最小值和最大值的范围内,或者像对您的问题的评论一样,它们被推到最小值或最大值。始终查看 Apple 的参考文档。
参考:http: //developer.apple.com/library/ios/#documentation/UIKit/Reference/UIStepper_Class/Reference/Reference.html

enter image description here

enter image description here

回答by SISYN

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

我想通了,我只是忘记在 viewDidLoad 方法中初始化步进器。对不起大家!

回答by vivek

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

我们可以使用以下语法设置步进器的值,

[your_stepper_name setValue:your_stepper_value];

[your_stepper_name setValue:your_stepper_value];

ex:

前任:

[stepper setValue:10];

[步进设置值:10];