从coredate加载后重设步进值 [英] Stepper value reset after loaded from coredate

查看:141
本文介绍了从coredate加载后重设步进值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个UITabledetail视图,其中包含一个步进器和一个UILabel.

I am building a UITabledetail view, which contains a stepper and a UILabel.

uilabel将显示按下的步进器数量.

The uilabel will show the number of stepper pressed.

当我使用核心数据保存uilabel的值时,我的问题来了.例如uilabel的最终值为30.

My problem comes when i used core data to save the value of the uilabel. e.g. the final value of the uilabel is 30.

当我重新加载数据时,uilabel显示为30,但是当我再次按下步进器时,uilabel再次重置为1.

When i load back the data, the uilabel showed 30 but, when i press the stepper again, the uilabel reset to 1 again.

有什么方法可以使步进器根据我保存的值继续计数吗?

Is there any way to make the stepper continue to count based on my saved value?

下面是我的代码.

- (IBAction)stepperValueChanged:(id)sender 
{
    double stepperValue = ourStepper.value;
    self.label.text = [NSString stringWithFormat:@"%.f", stepperValue];


  }

推荐答案

- (IBAction)stepperValueChanged:(id)sender 
{

    NSString *tempString = [NSString stringWithFormat:@"30"];// you can pass here whatever data(stepper value) that you retrieve from core data...
    double steppervalue = [tempString doubleValue];

    double stepperValue = ourStepper.value+steppervalue;
    self.label.text = [NSString stringWithFormat:@"%.f", stepperValue];


  }

希望,这会对您有所帮助.

Hope, this will help you..

这篇关于从coredate加载后重设步进值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆