所以我有一个简单的用户界面、一个开始按钮、一些文本/标签和一个进度条。单击“开始”按钮时,NSProgressIndicator应该动画。这是我的代码:
@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];
}
我检查了多个来源(Apple Developer Portal 等),但没有任何效果。我不必拥有 NSPIndicator,但如果可以的话,那就太好了。另外,这是我的 AppDelegate.h 文件:
#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