gpt4 book ai didi

ios - 我如何在 XCode 8 swift 中禁用某个功能

转载 作者:行者123 更新时间:2023-11-30 12:13:57 25 4
gpt4 key购买 nike

所以我制作了一个测验应用程序,当用户完成 10 个问题时,它会隐藏按钮并显示一个按钮以转到下一个问题。我最近添加了一个倒计时器,它可以工作,但是当他们完成测试时,计时器会继续,我想找到一种方法在他们完成测验时禁用它。因此,当他们已经完成时,他们不会被带到重试页面。希望这是有道理的!

更新计时器代码

internal func updateTimer()
{

counter = counter - 1
if(counter > 0)
{
ibCounter.text = String(counter)
}else{
self.performSegue(withIdentifier: "Segue13", sender: nil)
}
}

计时器代码。

timer = Timer.scheduledTimer(timeInterval: 1.0, target: self, selector: #selector(cricketTest1View.updateTimer), userInfo: nil, repeats: true)

这是我在用户完成测验时输入代码的部分

func PickQuestion(){

if Questions.count > 0{
QNumber = 0
QuestionLabel.text = Questions[QNumber].Question

AnswerNumber = Questions[QNumber].Answer

for i in 0..<Buttons.count{

Buttons[i].setTitle(Questions[QNumber].Answers[i], for: UIControlState())

}

Questions.remove(at: QNumber)
}
else{

QuestionLabel.text = "YOU HAVE COMPLETED THE QUIZ"
Button1.isHidden = true
Button2.isHidden = true
Button3.isHidden = true
Button4.isHidden = true
NextQuiz.isHidden = false
Start.isHidden = true
ibCounter.isHidden = true
}
}

最佳答案

测验完成后使用timer.invalidate()

它应该根据您的代码放在您的 else 部分中。

关于ios - 我如何在 XCode 8 swift 中禁用某个功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45657869/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com