gpt4 book ai didi

ios - 当应用程序流畅运行时,您如何测试 UIActivityIndi​​catorView 是否在旋转?

转载 作者:行者123 更新时间:2023-11-28 13:43:13 26 4
gpt4 key购买 nike

我的问题是您看不到 UIActivityIndi​​catorView,因为应用程序运行流畅,所以我不确定代码是否正确。

这里是提到它的所有内容:

@IBOutlet weak var questionLabel: UILabel!
@IBOutlet weak var scoreLabel: UILabel!
@IBOutlet var progressBar: UIView!
@IBOutlet weak var progressLabel: UILabel!
@IBOutlet weak var loadingIndicator: UIActivityIndicatorView!

override func viewDidLoad() {
super.viewDidLoad()
loadingIndicator.hidesWhenStopped.toggle()
nextQuestion()
}

func startOver() {
loadingIndicator.startAnimating()
questionNumber = 0
score = 0
nextQuestion()
}

func nextQuestion() {
updateUI()
loadingIndicator.stopAnimating()
if questionNumber <= 12 {

func updateUI() {

scoreLabel.text = "Score: \(score)"

progressBar.frame.size.width = (view.frame.size.width / 13) * CGFloat(questionNumber)


}

这不符合顺序。

最佳答案

您可以人为地向 nextQuestion() 添加延迟:

Timer.scheduledTimer(withTimeInterval: 1, repeats: false) { [weak self] _ in
self?.nextQuestion()
}

DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
self?.nextQuestion()
}

延迟将使您看到计时器在旋转。更好的方法是将您的服务层隐藏在协议(protocol)后面,然后您可以拥有一个模拟服务层,该服务层在延迟或出错后返回样本数据。这使您可以测试诸如加载动画和错误处理之类的事情。

关于ios - 当应用程序流畅运行时,您如何测试 UIActivityIndi​​catorView 是否在旋转?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55763828/

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