Comments (13)
So you have a UICircularTimerRing
, which is animating, the app enters background (before this you reset
) then you enter foreground and start
but you are noticing that the timer just speeds up? Is this correct?
If so, have you tried using pauseTimer
before entering background? And continueTimer
after re-entering foreground?
from uicircularprogressring.
Yes @luispadron , I have tried pauseTimer and continueTimer. I doesn't suit me, as after I use continueTimer it continues just from where it was paused. For example, if I was 20 seconds in foreground and 5 seconds in background, then I want my animation to start from 25 seconds. When I use pauseTimer and continueTimer, however, my app continues animation only from 20 seconds.
That is the reason why I use resetTimer and startTimer. When I use resetTimer and startTimer, however, the animation starts from the default startAngle, which is set to 0 (this is the angle, from which my timer and animation begin after being started for the first time). And because I have in my timer now new length (full time of the timer - time already spent), the animation is faster. It has to go the same length for faster time.
I guess it happens every time you use startTimer, so I don't know what to do...
from uicircularprogressring.
Ah, I see what you are trying to do now. For this use case we'd have to add some API which allows setting the time explicitly. Since when the app goes to the background UIKit does not render any animations.
Maybe something like setTime(_:)
or better yet something like continueTimer(adding: Double)
. This way you would call pauseTimer
before going to background then call continueTimer(adding: timeInBackground)
.
I'm currently busy working on v7.0 which still wont solve your issue (unless you plan on using SwiftUI). I can definitely help you implement this feature if you'd like to give it a shot, but otherwise I'd have to put it on the todo list as I'm a bit busy.
from uicircularprogressring.
Thinking about this more, this actually seems more like a bug than a feature. I'm not going to lie its been a while since I looked at UICircularTimerRing
source code and it looks like theres something happening in the pauseTimer
and continueTimer
methods which aren't allowing what you want above. I'll see if I can spend a few minutes tomorrow investigating it further.
from uicircularprogressring.
Thanks for your quick response, @luispadron ! I'll just be waiting for your solution, thanks!
from uicircularprogressring.
I need to implement this feature in 2 weeks (since I want to submit my app to App Store), so if you could find time to do it in this time frame it would help me a lot.
from uicircularprogressring.
@dvlpd So I just tried the use case you presented above and it seems like this is working as expected.
Notice in the gif how the timer starts, counts to 5 seconds then I enter the background (home) and wait a few seconds, when the app reopens the animation starts from the expected position.
from uicircularprogressring.
Wow! Great news, @luispadron ! Could you explain how did you manage to do that? Did you use reset/start or pause/continue? I tried both of these methods, so I need to understand where to focus my attention.
from uicircularprogressring.
One major correction: now I have a problem when I go to another Tab Bar View Controller and back. I have the same issue. My timer is in one of these Tab Bar View Controllers
from uicircularprogressring.
@luispadron Any updates, my friend?
from uicircularprogressring.
Haven't had much time as have been busy with other things.
For some reason it doesn't behave the same. I can't diagnose this much further since I've committed to working on the latest version of this lib.
from uicircularprogressring.
@luispadron Any updates, my friend?
from uicircularprogressring.
I have the same issue in TOTP app, using code from Legacy folder in UIKit.
Typical scenario that demonstrates the issue:
- start the timer, say from 0 to 60s, using this:
progressRing.startTimer(
from: startInterval,
to: timeInterval)
{
[weak self] state in
switch state {
case .finished:
self?.updateUI()
default:
break
}
}
updateUI
is called to re-do this same code for next TOTP period- during the period, lock the screen at 10s (out of 60) for 20s
- on screen unlock, it would briefly show 30s but then redraw into some random number between 10 and 30 and animates from there with increased speed and it would finish in proper time
I tried to call resetTimer
then call startTimer
on screen unlock but similar discrepancy happens.
I am completely lost in the code inside startTimer
method and not sure where to look for the source of the issue.
from uicircularprogressring.
Related Issues (20)
- UICircularProgressRing crashes on init(frame:) while running on iOS9 HOT 7
- Timer and Progress in the same screen HOT 2
- Module compiled with Swift 5.1.3 cannot be imported by the Swift 5.2.4 compiler HOT 4
- Want to add dash style for inner ring HOT 4
- Count-down Timer HOT 2
- support of dark mode change inside app HOT 1
- How can I make the knob got to the end vs. centered around the end
- Size and offset.
- Adding the library via SPM fails HOT 4
- Update the podspec file to include swiftUI updates HOT 1
- xcodebuild: error: Could not resolve package dependencies: Authentication failed because no credentials were provided HOT 3
- Cannot add legacy version via CocoaPods HOT 1
- In UICircularTimerRing give the option to be countdown rather than countup HOT 1
- Help: Customising the ValueKnob? HOT 1
- How to animation from two angle?
- Increase font size of percentage and add any label there
- Cannot find type 'UICircularProgressRing' in scope (installed via SPM) HOT 5
- Swift Compiler Warning - Deprecated protocol inheritance HOT 1
- luispadron/SnapshotTesting is not found.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uicircularprogressring.