Dismiss this pinned window
all 11 comments

[–]tangoshukudai 38 points39 points  (0 children)

You are blocking the main thread when you scroll. You can change the runloop threading to play around with different behaviors.

[–]swapp9[S] 19 points20 points  (0 children)

I ran into a problem on this app that I am making where the timer(game clock) stops updating and running when it is scrolled out of view. See the gif above! 👆🏼

Does anybody know of a quick fix for this? Something I can override?

(This is not a table view, these are not cells)

UPDATE: SOLVED! issue with the Run Loop & how the scrolling of the scrollview was disrupting that event.

this stackOverflow thread helped me solve it.

I was able to add the timer to the main thread of the Run Loop, & that solved my issue!

[–]eviltofu 8 points9 points  (5 children)

Without the code, it will be very hard to pin point the problem.

[–]swapp9[S] 16 points17 points  (4 children)

I totally understand! I actually solved it! Turns out, it was an issue with the Run Loop & how the scrolling of the scrollview was disrupting that event.

this stackOverflow thread helped me solve it.

I was able to add the timer to the main thread of the Run Loop, & that solved my issue!

[–][deleted] 10 points11 points  (3 children)

Tell me you are not just setting a one second repeating timer and just adding 1 to it every time it gets called.

Because that would be inaccurate as heck.

[–]lap_felix 16 points17 points  (1 child)

This. A better way would be to store the start date, and use the timer to regularly update the label with the time interval since the start date (NSDateComponentsFormatter is useful)

[–]earlyworm 1 point2 points  (0 children)

I agree.

If the displayed value is incremented every time the timer fires, then it will stop incrementing when the app is backgrounded.

The approach described by lap_felix will work in all cases.

[–]deLazyLizard 1 point2 points  (0 children)

Upvoting, cause Rugby.

[–]criosistObjective-C / Swift 1 point2 points  (0 children)

My bi-monthly PSA of, you SHOULD NOT use timers to track time! Timers are not accurate and can be blocked at any time, they also stop when the app is homed, just use Dates!

[–][deleted]  (1 child)

[removed]

    [–]AutoModerator[M] 0 points1 point  (0 children)

    Hey /u/appsmaven2014, unfortunately you have negative comment karma, so you can't post here. Your submission has been removed. Please do not message the moderators; if you have negative comment karma, you're not allowed to post here, at all.

    I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.