I am developing an Apple Watch application in which I am calling an API which takes some time to execute, so to show user process is going on I need to show Activity Indicator. I am trying hard to find the solution as there is no Activity Indicator included in Apple Watch. One solution is to take image and animate image when we start the process and hide when we get response but is there any better solution as we need to add multiple images?
4 Answers
Unfortunately, there is no activity indicator interface element in WatchKit. You can create your own using the technique you've described. That is, unhide and begin an animated image sequence while you're waiting for a response, and hide it when the operation is complete.
This is the exact same technique that I use in my own Watch app. In my case, I load 4 images, so there are 4 unique activity indicator images that "spin" while the images are retrieved.

- 3,337
- 1
- 17
- 15
Create custom Activity Indicator using WKInterfaceImage
like this;
IBOutlet WKInterfaceImage *animatedImage;
Now add images in sequence for animation in WKInterfaceImage
in Images.xcassets
The method for hiding and unhiding activity indicator :
-(void)showActivityIndicator:(BOOL)yesOrNo
{
if (yesOrNo)
{
//unhide
[self.animatedImage setHidden:NO];
// Uses images in WatchKit app bundle.
[self.animatedImage setImageNamed:@"ActInd"];
[self.animatedImage startAnimating];
}
else
{
[self.animatedImage stopAnimating];
//hide
[self.animatedImage setHidden:YES];
}
}

- 38,095
- 11
- 81
- 132
We can use WKInterfaceImage set Images spinner@2x1.png and then animate image using startAnimatingWithImagesInRange
Now add images in sequence for animation in WKInterfaceImage in Images.x cassets spinner@2x1.png,spinner@2x2.png.....spinner@2x40.png
Then use following method
NSRange model = NSMakeRange(0, 40);
/* set Image to ImageView */
[self.spinnerImage setImageNamed:@"spinner@2x1.png"];
/* set repeat count 0 for continues rotation */
[self.spinnerImage startAnimatingWithImagesInRange:model
duration:1.0
repeatCount:0];
This method works but it not smooth and if need set in center of view, then image needs to hidden first then unhide and animate image while process is going on and again hide after we get response,and if their multiple view then it becomes hectic is there any way to add image above all views or create dynamic activity indicator so that we add any where we need

- 37
- 3
'WatchKithas no UI control like
ActivityIndicator, but we can create custom activityIndicator with the help of
WKInterfaceImage`.
You can find more more detail on this stackoverflow-link.

- 1
- 1

- 1,523
- 10
- 24