I've tried figuring this out on my own, and am completely clueless as to how to accomplish it. Essentially what I'm trying to do is this:
The Overall Goal: Use the UIProgressView
as a "different type" of indicator than what it's meant for.
Details: When a user 'completes' a 'goal' (by pressing a UIButton named "complete" in a separate UIViewController
, let's call this one "View Controller 1") I'd like it to update a UIProgressView in a second UIViewController
(call this one "View Controller 2"). There are several UIProgressViews
in View Controller 2, each representing the # of goals in a category 'completed'. So I'd like to have a void method in View Controller
2 like this:
(void)progressMade:(NSString *)category
{
categoryOneProgressView.progress += 1/8 ;
//this would be called from View Controller 1, after the "complete" button was pressed.
}
Thank you in advance for your help.
What you can do is on Touching of Button in VIEW CONTROLLER 1 you store the Value of the goals completed in a particular category. Example Code for View Controller 1:
-(void)methodTriggeredOnCompleted:(NSString *)category
{
//Do you calculation for progress of a category
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setValue:saveProgressValue forKey:category];
[defaults synchronize];
}
Now in View Controller 2 what you should do is in ViewDidLoad method or in ViewWillAppear method you should get the value you stored in NSUserDefaults and update it in progress bar value
-(void)viewDidLoad
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
int val = [defaults valueForKey:category];
categoryOneProgressBar.progress = val;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.