1

好的,让我概述一下到目前为止发生的情况。我在一个数组中有三个问题。每次按下“下一步”按钮时,它都会滑到数组中的下一个问题。我想要发生的是,当按下数组中的下一个问题时,它会移动进度条。我不需要对进度条的值做任何事情,它只是为了设计而存在。

目前,我已经设置好了代码,所以当你第一次按下 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)

    }
4

1 回答 1

1

我不确定此时的解决方法是什么,因为我目前仍在学习 swift,所以给你一个想法。但我认为这是您设置的值,即 0.333。使用您现在拥有的代码,您将其设置为值 0.333,而不是增加 0.333。也许您可以在问题中使用 if 循环。像,如果问题 == 1,setProgress(0.333),如果问题 == 2,setProgress(0.666)

于 2015-05-13T21:27:19.280 回答