Finished Everything - fix time display and hiding buttons
This commit is contained in:
@@ -30,11 +30,13 @@ class StopwatchViewController: UIViewController {
|
|||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
// Do any additional setup after loading the view.
|
//lapButton.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func start(_ sender: UIButton) {
|
@IBAction func start(_ sender: UIButton) {
|
||||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(count), userInfo: nil, repeats: true)
|
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(count), userInfo: nil, repeats: true)
|
||||||
|
//startButton.isHidden = true
|
||||||
|
//lapButton.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc fileprivate func count() {
|
@objc fileprivate func count() {
|
||||||
@@ -49,7 +51,7 @@ class StopwatchViewController: UIViewController {
|
|||||||
minutes = 0
|
minutes = 0
|
||||||
}
|
}
|
||||||
if hours == 24 {
|
if hours == 24 {
|
||||||
timer.invalidate()
|
resetTimes()
|
||||||
}
|
}
|
||||||
|
|
||||||
if seconds >= 10 { secondLabel.text = "\(seconds)" }
|
if seconds >= 10 { secondLabel.text = "\(seconds)" }
|
||||||
@@ -62,9 +64,25 @@ class StopwatchViewController: UIViewController {
|
|||||||
|
|
||||||
@IBAction func stop(_ sender: UIButton) {
|
@IBAction func stop(_ sender: UIButton) {
|
||||||
timer.invalidate()
|
timer.invalidate()
|
||||||
|
//startButton.isHidden = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func reset(_ sender: UIButton) {
|
@IBAction func reset(_ sender: UIButton) {
|
||||||
|
resetTimes()
|
||||||
|
}
|
||||||
|
|
||||||
|
func resetTimes() {
|
||||||
|
seconds = 0
|
||||||
|
minutes = 0
|
||||||
|
seconds = 0
|
||||||
|
lappedTimes = []
|
||||||
|
timer.invalidate()
|
||||||
|
secondLabel.text = "00"
|
||||||
|
minuteLabel.text = "00"
|
||||||
|
hourLabel.text = "00"
|
||||||
|
tableView.reloadData()
|
||||||
|
//startButton.isHidden = false
|
||||||
|
//lapButton.isHidden = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func lap(_ sender: UIButton) {
|
@IBAction func lap(_ sender: UIButton) {
|
||||||
|
|||||||
Reference in New Issue
Block a user