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

时光毁灭记忆、已成空白 提交于 2019-12-11 04:54:39

问题


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?


回答1:


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




回答2:


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




回答3:


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

[your_stepper_name setValue:your_stepper_value];

ex:

[stepper setValue:10];



来源:https://stackoverflow.com/questions/13805263/can-you-set-a-default-current-value-for-uistepper-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!