1

I would like to load the progressview's status, when I start my app again. I have an int, which I save every time. the progressview is full if the int = 18.

I used this code:

IBOutlet UIProgressView *progress1;


-(void)progress1{
    [progress1  setProgress:progress1.progress+0.055];

}

in viewdidappear/viewdidload:

[progress1 setProgress:0.0];

so if I answered 9/18 , and my progress bar is at half, and I close my app, next time when I start again, it still at half, not 0.0

4

1 回答 1

1

在您的按钮按下方法中添加:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setFloat:[progress1 progress] forKey:@"progress"];
[defaults synchronize];

在你的viewDidLoad

[progress1 setProgress:[[NSUserDefaults standardUserDefaults] floatForKey:@"progress"];
于 2013-01-13T01:58:53.080 回答