I'm building a small app for apple watch. I have a Group and a Label inside of it. What I'm trying to do is:
My code looks essentially like this:
group.setBackgroundImageNamed("show_back-");
group.startAnimatingWithImagesInRange(NSMakeRange(0, 39), duration: 1.5, repeatCount: 1);
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1.5 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) { () -> Void in
self.animateWithDuration(1) { () -> Void in
self.label.setAlpha(1)
};
};
The problem is that the first time this sequence is triggered, the image animation seems to run slower than 1.5 seconds, because the label starts fading in earlier than the images stop changing. If this is triggered again while the app is running, everything works as expected. I guess it has something to do with images preloading or something.
How can I make it work consistently? I couldn't find any sort of callback on image sequence animation end to subscribe to.
EDIT Another problem I've noticed: I have another case when bg is animated from a dispatch_after block, and when I leave the app by tapping the crown and return by double-tapping it, either the dispatch_after block is not triggered, or the background animation is not rendered correctly the first time it is invoked (I think the second, because I tried adding a breakpoint into the dispatch block and it triggered every time I tested). I'm running watchOS2, so maybe it is related to the beta state the OS is currently in?
How to fix slow performance problem on your Apple Watch 4, working very slow. Performance problems in smart devices are usually due to memory issues like when the memory space is running low. Software bugs, bad apps, faulty updates and in worst case scenarios, hardware damage are among the underlying causes.
On a support page detailing the 'feature', Apple has confirmed that “This power management feature is specific to iPhone and does not apply to any other Apple products.” That is to say, Apple isn't slowing your Apple Watch down.
Apple requires it to be around 50% usually, but using Wi-Fi consumes much more battery. Then connect your iPhone to its charger and hold it near the Watch. Next, if you have an Apple Watch Series 6 or later, you should ideally connect to a 5GHz network, not 2.4GHz. This will help your update download faster.
I ran into the same issue as you.
This happens because on the first time you try it, the watch takes time to load the images. Also apple doesn't give us any 'pre load' method, so I came up with a little work around it: When my controller will be displayed:
func willActivate()
I play the animation sequence once in a background tread, this way when my user clicks on it the images are already loaded.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) { [weak self] in
if let uSelf = self {
uSelf.statusAnimationImage.setImageNamed("my image name")
uSelf.statusAnimationImage.startAnimatingWithImagesInRange(NSMakeRange(0, 359), duration: 0.5, repeatCount: 1)
}
}
That was the best way I found to solve this problem and it works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With