Skip to content

Instantly share code, notes, and snippets.

@zorgiepoo
Created November 11, 2013 00:24
Show Gist options
  • Save zorgiepoo/7405858 to your computer and use it in GitHub Desktop.
Save zorgiepoo/7405858 to your computer and use it in GitHub Desktop.
Spinning progress indicator troubles, ugh
#import "ZGAppDelegate.h"
@interface ZGAppDelegate ()
@property (nonatomic) NSTimer *timer;
@property (assign) IBOutlet NSProgressIndicator *progressIndicator;
@end
@implementation ZGAppDelegate
// Progress indicator starts out as determinate in IB
// Display when stopped is unchecked
// Auto layout is on
// Three buttons - deterministic, indeterminstic, stop
// See https://dl.dropboxusercontent.com/u/10108199/deterministic.mov for the glitch in action
- (void)animate
{
[self.progressIndicator incrementBy:1];
}
- (IBAction)makeDeterminate:(id)sender
{
[self.progressIndicator setHidden:NO];
[self.progressIndicator setIndeterminate:NO];
self.progressIndicator.minValue = 0;
self.progressIndicator.doubleValue = 0;
self.progressIndicator.maxValue = 10;
self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(animate) userInfo:nil repeats:YES];
}
- (IBAction)makeIndeterminate:(id)sender
{
[self.progressIndicator setHidden:NO];
[self.progressIndicator setIndeterminate:YES];
[self.progressIndicator startAnimation:self];
}
- (IBAction)stopProgressIndicator:(id)sender
{
if (self.progressIndicator.isIndeterminate)
{
[self.progressIndicator stopAnimation:self];
}
else
{
[self.timer invalidate];
self.timer = nil;
}
[self.progressIndicator setHidden:YES]; // If I comment this line out and don't hide the indicator, I don't run into the glitch
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment