OGeek|极客世界-中国程序员成长平台

标题: ios - 有没有办法根据计算以编程方式更改 UIStepper 的值? [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 12:05
标题: ios - 有没有办法根据计算以编程方式更改 UIStepper 的值?

假设我有 3 个 UIStepper
当我改变一个的值时,其他步进器的值会根据一个公式而改变。

Stepper 1 的值为 10。
Stepper 2 的值为 5。
步进三的值为 3。

如果我更改步进器 10 +/- 1,它可能会更改步进器 2 +/- 1 中的值。

这可能吗?



Best Answer-推荐答案


绝对有可能。

你可以想象这样的场景:

UIStepper *stepperOne = [[UIStepper alloc] initWithFrame:frame];
[stepperOne addTarget:self actionselector(stepperOneChanged forControlEvents:UIControlEventValueChanged];

- (void)stepperOneChangedUIStepper*)stepperOne{
    //This method would be called on the target of your first stepper on UIControlEventsValueChanged

    //Decrease the value by 1
    stepperTwo.value --;

    //OR
    //Increase the value by 1
    stepperTwo.value ++;
}

关于ios - 有没有办法根据计算以编程方式更改 UIStepper 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9627856/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4