I'm a beginner and I'm trying to write and application for iOS that will show to the user in the main screen a timer from 25 minutes to 0 (made of a UILabel
whom text is updated every second using an NSTimer
) and a UITableView
(embedded in the UIViewController
of the main screen) that will show a cell for each time the timer as reached the 0.
So in the main view controlled by my UIViewController
I have:
- UILabel
: for the timer
- UITableView
: wich shows a cell for each time the timer as reached 0
- UIButton
: to start the timer
Everything seems to work fine except for the fact that scrolling the UITableView
will stop the timer from updating the label as long as the user keeps the finger on the tablewView. Can anyone tell me why the label won't change its text while the UITableView
is being scrolled?
P.S. I think that this problem could be related to the fact that I'm not using threads since I've not learned to use them yet.
Solution in Swift 3.x:
self.updateTimer = Timer.scheduledTimer(timeInterval:1.0, target: self, selector: "updateFunction", userInfo: nil, repeats: true)
RunLoop.current.add(self.updateTimer, forMode: RunLoopMode.commonModes)
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