好的,让我概述一下到目前为止发生的情况。我在一个数组中有三个问题。每次按下“下一步”按钮时,它都会滑到数组中的下一个问题。我想要发生的是,当按下数组中的下一个问题时,它会移动进度条。我不需要对进度条的值做任何事情,它只是为了设计而存在。
目前,我已经设置好了代码,所以当你第一次按下 Next 按钮时,它会将进度条移动到值 0.333,但是当你再次按下它时,它不再移动,它只是停留在原处它是。
有人可以帮忙吗,因为我一直在尝试解决这个问题,但没有运气。我的代码显示了我必须使其最初移动的内容如下:
@IBOutlet var progressStatus: UIProgressView!
@IBAction func nextButton(sender: AnyObject) {
// Displays the questions in array and displays the placeholder text in the textfield
if currentQuestionIndex <= questions.count && currentPlaceholderIndex <= placeholder.count {
currentQuestionIndex++
currentPlaceholderIndex++
progressStatus.setProgress(0.333, animated: true)
buttonLabel.setTitle("Next", forState: UIControlState.Normal)
}
提前致谢!
回答我的问题的代码:
if currentQuestionIndex == 0 {
progressStatus.setProgress(0.333, animated: true)
} else if currentQuestionIndex == 1 {
progressStatus.setProgress(0.666, animated: true)
} else {
progressStatus.setProgress(1, animated: true)
}