Indeterminate NSProgressIndicator will not animate
Asked Answered
E

1

10

So I've got a simple UI, A Start button, some text/labels, and a progress bar. When the Start button is click, the NSProgressIndicator should animate. Here's my code:

@synthesize progressBar = progressBar;
 /* Some code and setup stuffs... */
- (IBAction)startAction:(id)sender {
    NSLog(@"Button clicked.");
    NSLog(@"Beginning Socketry and socket creation...");
    [progressBar setUsesThreadedAnimation:YES];
    [progressBar setIndeterminate:YES];
    [progressBar startAnimation:progressBar];
}

I've checked multiple source (Apple Developer Portal, etc.), and nothing works. I don't have to have the NSPIndicator, but it would be really nice if I could. Also, here's my AppDelegate.h file:

#import <Cocoa/Cocoa.h>

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;

@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (weak) IBOutlet NSProgressIndicator *progressBar;
- (IBAction)saveAction:(id)sender;

- (IBAction)startAction:(id)sender;

- (IBAction)changeStatus:(id)sender;

- (IBAction)changeProgress:(id)sender;

@end
Especial answered 13/2, 2013 at 19:24 Comment(3)
Have you verified that progressBar is not nil (NSLog(@"Progress Bar: %@", progressBar);) ? If nil set your connection in IB. Also make sure you did not override it by setting it to a new progress bar that has not been added to the view hierarchy.Condescending
Well, I did what you said and it's not nil, but I'm going to just try something real quick. Actually, I just deleted the reference in header file, and re-dropped the reference from the .xib, and ran it again, clicked the start button, and it worked perfectly! I think it was the second issue you stated, overriding the original. I literally just started learning Objective-C the other day, and its syntax is very confusing to me. Thank you for your help! :DEspecial
@Especial when you start to see objects that can talk together it get's easierTutto
U
15

Go to the Attributes Inspector of the Progress Indicator and set up as shown in the picture below:

enter image description here

See code below:

@synthesize progressBar;
- (IBAction)startAction:(id)sender {
    [progressBar setHidden:NO];
    [progressBar setIndeterminate:YES];
    [progressBar setUsesThreadedAnimation:YES];
    [progressBar startAnimation:nil];
}
Utta answered 12/6, 2014 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.