I have previously worked on IOS but just started to work on MacOsX cocoa application. I had an issue regarding the NSProgressIndicator
.
When I create the application I had the appdelegate. h & .m and a mainmenu.xib. I added the Indeterminate Progress Indicator to the MainMenu.xib and in my Appdelegate.h file connected this to an instance of NSProgressIndicator
using IBOutlet
.
@property (nonatomic, retain) IBOutlet NSProgressIndicator* activityIndicator;
In my Appdelegate.m file I do this:
activityIndicator = [[NSProgressIndicator alloc]initWithFrame:NSMakeRect(206,82,120,120)];
[activityIndicator setStyle:NSProgressIndicatorSpinningStyle];
[activityIndicator startAnimation:nil];
When I run the program, I can see the progress bar (as expected), but it does not animate. Any solution would be of great help and if its an logical error please do explain so that I can learn. Thanks a ton.
This is what you are doing currently:
You basically create a completely new instance of progress view and want to animate that, instead of the one that is loaded from the nib file. The reason why it doesn't actually animate is, because the progress view you see when you run your app is the one from interface builder (that you don't animate). The one you create programmatically you don't add to the view hierarchy, so that one is invisible.
You have to either create the progress view in Interface Builder, assign the outlet and then use it, i.e. remove this line:
Or you can programmatically create the progress view, but then you have to add it to your view.
If you want to modify the position of the progress view that was loaded from the nib file, set the frame property instead of creating a new instance.